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

Side by Side Diff: util/mach/child_port_server_test.cc

Issue 799463003: MachMessageServer::Interface implementations: minor cleanups (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 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
« no previous file with comments | « util/mach/child_port_server.cc ('k') | util/mach/exc_server_variants.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 }; 87 };
88 88
89 class MockChildPortServerInterface : public ChildPortServer::Interface { 89 class MockChildPortServerInterface : public ChildPortServer::Interface {
90 public: 90 public:
91 MOCK_METHOD6(HandleChildPortCheckIn, 91 MOCK_METHOD6(HandleChildPortCheckIn,
92 kern_return_t(child_port_server_t server, 92 kern_return_t(child_port_server_t server,
93 const child_port_token_t token, 93 const child_port_token_t token,
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_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; 104 std::set<mach_msg_id_t> expect_request_ids;
105 expect_request_ids.insert(10011); // There is no constant for this. 105 expect_request_ids.insert(10011); // There is no constant for this.
106 EXPECT_EQ(expect_request_ids, server.MachMessageServerRequestIDs()); 106 EXPECT_EQ(expect_request_ids, server.MachMessageServerRequestIDs());
107 107
108 ChildPortCheckInRequest request; 108 ChildPortCheckInRequest request;
109 EXPECT_LE(request.Head.msgh_size, server.MachMessageServerRequestSize()); 109 EXPECT_EQ(request.Head.msgh_size, server.MachMessageServerRequestSize());
110 110
111 MIGReply reply; 111 MIGReply reply;
112 EXPECT_LE(sizeof(reply), server.MachMessageServerReplySize()); 112 EXPECT_EQ(sizeof(reply), server.MachMessageServerReplySize());
113 113
114 EXPECT_CALL(server_interface, 114 EXPECT_CALL(server_interface,
115 HandleChildPortCheckIn(kServerLocalPort, 115 HandleChildPortCheckIn(kServerLocalPort,
116 kCheckInToken, 116 kCheckInToken,
117 kCheckInPort, 117 kCheckInPort,
118 kCheckInPortRightType, 118 kCheckInPortRightType,
119 Eq(&request.trailer), 119 Eq(&request.trailer),
120 Pointee(Eq(false)))) 120 Pointee(Eq(false))))
121 .WillOnce(Return(MIG_NO_REPLY)) 121 .WillOnce(Return(MIG_NO_REPLY))
122 .RetiresOnSaturation(); 122 .RetiresOnSaturation();
123 123
124 bool destroy_complex_request = false; 124 bool destroy_request = false;
125 EXPECT_TRUE(server.MachMessageServerFunction( 125 EXPECT_TRUE(server.MachMessageServerFunction(
126 reinterpret_cast<mach_msg_header_t*>(&request), 126 reinterpret_cast<mach_msg_header_t*>(&request),
127 reinterpret_cast<mach_msg_header_t*>(&reply), 127 reinterpret_cast<mach_msg_header_t*>(&reply),
128 &destroy_complex_request)); 128 &destroy_request));
129 EXPECT_FALSE(destroy_complex_request); 129 EXPECT_FALSE(destroy_request);
130 130
131 reply.Verify(); 131 reply.Verify();
132 } 132 }
133 133
134 } // namespace 134 } // namespace
135 } // namespace test 135 } // namespace test
136 } // namespace crashpad 136 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/mach/child_port_server.cc ('k') | util/mach/exc_server_variants.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698