OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 mach_port_t port, | 94 mach_port_t port, |
95 mach_msg_type_name_t right_type, | 95 mach_msg_type_name_t right_type, |
96 const mach_msg_trailer_t* trailer, | 96 const mach_msg_trailer_t* trailer, |
97 bool* destroy_complex_request)); | 97 bool* destroy_complex_request)); |
98 }; | 98 }; |
99 | 99 |
100 TEST(ChildPortServer, MockChildPortCheckIn) { | 100 TEST(ChildPortServer, MockChildPortCheckIn) { |
101 MockChildPortServerInterface server_interface; | 101 MockChildPortServerInterface server_interface; |
102 ChildPortServer server(&server_interface); | 102 ChildPortServer server(&server_interface); |
103 | 103 |
| 104 std::set<mach_msg_id_t> expect_request_ids; |
| 105 expect_request_ids.insert(10011); // There is no constant for this. |
| 106 EXPECT_EQ(expect_request_ids, server.MachMessageServerRequestIDs()); |
| 107 |
104 ChildPortCheckInRequest request; | 108 ChildPortCheckInRequest request; |
105 EXPECT_LE(request.Head.msgh_size, server.MachMessageServerRequestSize()); | 109 EXPECT_LE(request.Head.msgh_size, server.MachMessageServerRequestSize()); |
106 | 110 |
107 MIGReply reply; | 111 MIGReply reply; |
108 EXPECT_LE(sizeof(reply), server.MachMessageServerReplySize()); | 112 EXPECT_LE(sizeof(reply), server.MachMessageServerReplySize()); |
109 | 113 |
110 EXPECT_CALL(server_interface, | 114 EXPECT_CALL(server_interface, |
111 HandleChildPortCheckIn(kServerLocalPort, | 115 HandleChildPortCheckIn(kServerLocalPort, |
112 kCheckInToken, | 116 kCheckInToken, |
113 kCheckInPort, | 117 kCheckInPort, |
114 kCheckInPortRightType, | 118 kCheckInPortRightType, |
115 Eq(&request.trailer), | 119 Eq(&request.trailer), |
116 Pointee(Eq(false)))) | 120 Pointee(Eq(false)))) |
117 .WillOnce(Return(MIG_NO_REPLY)) | 121 .WillOnce(Return(MIG_NO_REPLY)) |
118 .RetiresOnSaturation(); | 122 .RetiresOnSaturation(); |
119 | 123 |
120 bool destroy_complex_request = false; | 124 bool destroy_complex_request = false; |
121 EXPECT_TRUE(server.MachMessageServerFunction( | 125 EXPECT_TRUE(server.MachMessageServerFunction( |
122 reinterpret_cast<mach_msg_header_t*>(&request), | 126 reinterpret_cast<mach_msg_header_t*>(&request), |
123 reinterpret_cast<mach_msg_header_t*>(&reply), | 127 reinterpret_cast<mach_msg_header_t*>(&reply), |
124 &destroy_complex_request)); | 128 &destroy_complex_request)); |
125 EXPECT_FALSE(destroy_complex_request); | 129 EXPECT_FALSE(destroy_complex_request); |
126 | 130 |
127 reply.Verify(); | 131 reply.Verify(); |
128 } | 132 } |
129 | 133 |
130 } // namespace | 134 } // namespace |
131 } // namespace test | 135 } // namespace test |
132 } // namespace crashpad | 136 } // namespace crashpad |
OLD | NEW |