OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 5 #include <stdint.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 #include <sstream> | 9 #include <sstream> |
10 #include <string> | 10 #include <string> |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 IPC::Message::PRIORITY_NORMAL); | 178 IPC::Message::PRIORITY_NORMAL); |
179 message->WriteInt(reply + 1); | 179 message->WriteInt(reply + 1); |
180 message->WriteInt(reply); | 180 message->WriteInt(reply); |
181 return other_->Send(message); | 181 return other_->Send(message); |
182 } | 182 } |
183 | 183 |
184 void Cleanup() { | 184 void Cleanup() { |
185 --message_count_; | 185 --message_count_; |
186 --pending_messages_; | 186 --pending_messages_; |
187 if (0 == message_count_) | 187 if (0 == message_count_) |
188 base::MessageLoop::current()->Quit(); | 188 base::MessageLoop::current()->QuitWhenIdle(); |
189 } | 189 } |
190 | 190 |
191 void ReplyMsgNotHandled(uint32_t type_id) { | 191 void ReplyMsgNotHandled(uint32_t type_id) { |
192 RoundtripAckReply(FUZZER_ROUTING_ID, MsgUnhandled::ID, type_id); | 192 RoundtripAckReply(FUZZER_ROUTING_ID, MsgUnhandled::ID, type_id); |
193 Cleanup(); | 193 Cleanup(); |
194 } | 194 } |
195 | 195 |
196 void UseData(int caller, int value, const base::string16& text) { | 196 void UseData(int caller, int value, const base::string16& text) { |
197 std::ostringstream os; | 197 std::ostringstream os; |
198 os << "IPC fuzzer:" << caller << " [" << value << " " | 198 os << "IPC fuzzer:" << caller << " [" << value << " " |
199 << base::UTF16ToUTF8(text) << "]\n"; | 199 << base::UTF16ToUTF8(text) << "]\n"; |
200 std::string output = os.str(); | 200 std::string output = os.str(); |
201 LOG(WARNING) << output; | 201 LOG(WARNING) << output; |
202 } | 202 } |
203 | 203 |
204 int message_count_; | 204 int message_count_; |
205 int pending_messages_; | 205 int pending_messages_; |
206 }; | 206 }; |
207 | 207 |
208 class FuzzerClientListener : public SimpleListener { | 208 class FuzzerClientListener : public SimpleListener { |
209 public: | 209 public: |
210 FuzzerClientListener() : last_msg_(NULL) { | 210 FuzzerClientListener() : last_msg_(NULL) { |
211 } | 211 } |
212 | 212 |
213 bool OnMessageReceived(const IPC::Message& msg) override { | 213 bool OnMessageReceived(const IPC::Message& msg) override { |
214 last_msg_ = new IPC::Message(msg); | 214 last_msg_ = new IPC::Message(msg); |
215 base::MessageLoop::current()->Quit(); | 215 base::MessageLoop::current()->QuitWhenIdle(); |
216 return true; | 216 return true; |
217 } | 217 } |
218 | 218 |
219 bool ExpectMessage(int value, uint32_t type_id) { | 219 bool ExpectMessage(int value, uint32_t type_id) { |
220 if (!MsgHandlerInternal(type_id)) | 220 if (!MsgHandlerInternal(type_id)) |
221 return false; | 221 return false; |
222 int msg_value1 = 0; | 222 int msg_value1 = 0; |
223 int msg_value2 = 0; | 223 int msg_value2 = 0; |
224 base::PickleIterator iter(*last_msg_); | 224 base::PickleIterator iter(*last_msg_); |
225 if (!iter.ReadInt(&msg_value1)) | 225 if (!iter.ReadInt(&msg_value1)) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 // thrown out of sync by the extra argument. | 364 // thrown out of sync by the extra argument. |
365 msg = new MsgClassIS(3, base::ASCIIToUTF16("expect three")); | 365 msg = new MsgClassIS(3, base::ASCIIToUTF16("expect three")); |
366 sender()->Send(msg); | 366 sender()->Send(msg); |
367 EXPECT_TRUE(listener.ExpectMessage(3, MsgClassIS::ID)); | 367 EXPECT_TRUE(listener.ExpectMessage(3, MsgClassIS::ID)); |
368 | 368 |
369 EXPECT_TRUE(WaitForClientShutdown()); | 369 EXPECT_TRUE(WaitForClientShutdown()); |
370 DestroyChannel(); | 370 DestroyChannel(); |
371 } | 371 } |
372 | 372 |
373 } // namespace | 373 } // namespace |
OLD | NEW |