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

Side by Side Diff: ipc/ipc_fuzzing_tests.cc

Issue 8437033: Android IPC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: apply dmac feedback plus sync/merge Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_channel_posix_unittest.cc ('k') | ipc/ipc_message_macros.h » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <stdio.h> 5 #include <stdio.h>
6 #include <string> 6 #include <string>
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 348
349 EXPECT_TRUE(base::WaitForSingleProcess(server_process, 5000)); 349 EXPECT_TRUE(base::WaitForSingleProcess(server_process, 5000));
350 base::CloseProcessHandle(server_process); 350 base::CloseProcessHandle(server_process);
351 } 351 }
352 352
353 // This class is for testing the IPC_BEGIN_MESSAGE_MAP_EX macros. 353 // This class is for testing the IPC_BEGIN_MESSAGE_MAP_EX macros.
354 class ServerMacroExTest { 354 class ServerMacroExTest {
355 public: 355 public:
356 ServerMacroExTest() : unhandled_msgs_(0) { 356 ServerMacroExTest() : unhandled_msgs_(0) {
357 } 357 }
358
358 virtual ~ServerMacroExTest() { 359 virtual ~ServerMacroExTest() {
359 } 360 }
361
360 virtual bool OnMessageReceived(const IPC::Message& msg) { 362 virtual bool OnMessageReceived(const IPC::Message& msg) {
361 bool msg_is_ok = false; 363 bool msg_is_ok = false;
362 IPC_BEGIN_MESSAGE_MAP_EX(ServerMacroExTest, msg, msg_is_ok) 364 IPC_BEGIN_MESSAGE_MAP_EX(ServerMacroExTest, msg, msg_is_ok)
363 IPC_MESSAGE_HANDLER(MsgClassIS, OnMsgClassISMessage) 365 IPC_MESSAGE_HANDLER(MsgClassIS, OnMsgClassISMessage)
364 IPC_MESSAGE_HANDLER(MsgClassSI, OnMsgClassSIMessage) 366 IPC_MESSAGE_HANDLER(MsgClassSI, OnMsgClassSIMessage)
365 IPC_MESSAGE_UNHANDLED(++unhandled_msgs_) 367 IPC_MESSAGE_UNHANDLED(++unhandled_msgs_)
366 IPC_END_MESSAGE_MAP_EX() 368 IPC_END_MESSAGE_MAP_EX()
367 return msg_is_ok; 369 return msg_is_ok;
368 } 370 }
369 371
370 int unhandled_msgs() const { 372 int unhandled_msgs() const {
371 return unhandled_msgs_; 373 return unhandled_msgs_;
372 } 374 }
373 375
374 private: 376 private:
375 void OnMsgClassISMessage(int value, const std::wstring& text) { 377 void OnMsgClassISMessage(int value, const std::wstring& text) {
376 } 378 }
377 void OnMsgClassSIMessage(const std::wstring& text, int value) { 379 void OnMsgClassSIMessage(const std::wstring& text, int value) {
378 } 380 }
379 381
380 int unhandled_msgs_; 382 int unhandled_msgs_;
383
384 DISALLOW_COPY_AND_ASSIGN(ServerMacroExTest);
381 }; 385 };
382 386
383 TEST_F(IPCFuzzingTest, MsgMapExMacro) { 387 TEST_F(IPCFuzzingTest, MsgMapExMacro) {
384 IPC::Message* msg = NULL; 388 IPC::Message* msg = NULL;
385 ServerMacroExTest server; 389 ServerMacroExTest server;
386 390
387 // Test the regular messages. 391 // Test the regular messages.
388 msg = new MsgClassIS(3, L"text3"); 392 msg = new MsgClassIS(3, L"text3");
389 EXPECT_TRUE(server.OnMessageReceived(*msg)); 393 EXPECT_TRUE(server.OnMessageReceived(*msg));
390 delete msg; 394 delete msg;
(...skipping 12 matching lines...) Expand all
403 msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassIS::ID, 407 msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassIS::ID,
404 IPC::Message::PRIORITY_NORMAL); 408 IPC::Message::PRIORITY_NORMAL);
405 msg->WriteInt(0x64); 409 msg->WriteInt(0x64);
406 msg->WriteInt(0x32); 410 msg->WriteInt(0x32);
407 EXPECT_FALSE(server.OnMessageReceived(*msg)); 411 EXPECT_FALSE(server.OnMessageReceived(*msg));
408 delete msg; 412 delete msg;
409 413
410 EXPECT_EQ(0, server.unhandled_msgs()); 414 EXPECT_EQ(0, server.unhandled_msgs());
411 #endif 415 #endif
412 } 416 }
OLDNEW
« no previous file with comments | « ipc/ipc_channel_posix_unittest.cc ('k') | ipc/ipc_message_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698