| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // Unit test for SyncChannel. | 5 // Unit test for SyncChannel. |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 : Worker(Channel::MODE_CLIENT, "recursive_client"), | 477 : Worker(Channel::MODE_CLIENT, "recursive_client"), |
| 478 pump_during_send_(pump_during_send), close_channel_(close_channel) { } | 478 pump_during_send_(pump_during_send), close_channel_(close_channel) { } |
| 479 | 479 |
| 480 void OnDoubleDelay(int in, Message* reply_msg) { | 480 void OnDoubleDelay(int in, Message* reply_msg) { |
| 481 int answer = 0; | 481 int answer = 0; |
| 482 IPC::SyncMessage* msg = new SyncChannelTestMsg_Double(5, &answer); | 482 IPC::SyncMessage* msg = new SyncChannelTestMsg_Double(5, &answer); |
| 483 if (pump_during_send_) | 483 if (pump_during_send_) |
| 484 msg->EnableMessagePumping(); | 484 msg->EnableMessagePumping(); |
| 485 bool result = Send(msg); | 485 bool result = Send(msg); |
| 486 DCHECK(result != close_channel_); | 486 DCHECK(result != close_channel_); |
| 487 if (!close_channel_) { | 487 if (close_channel_) { |
| 488 delete reply_msg; |
| 489 } else { |
| 488 SyncChannelTestMsg_Double::WriteReplyParams(reply_msg, in * 2); | 490 SyncChannelTestMsg_Double::WriteReplyParams(reply_msg, in * 2); |
| 489 Send(reply_msg); | 491 Send(reply_msg); |
| 490 } | 492 } |
| 491 Done(); | 493 Done(); |
| 492 } | 494 } |
| 493 | 495 |
| 494 void OnAnswerDelay(Message* reply_msg) { | 496 void OnAnswerDelay(Message* reply_msg) { |
| 495 if (close_channel_) { | 497 if (close_channel_) { |
| 498 delete reply_msg; |
| 496 CloseChannel(); | 499 CloseChannel(); |
| 497 } else { | 500 } else { |
| 498 SyncChannelTestMsg_AnswerToLife::WriteReplyParams(reply_msg, 42); | 501 SyncChannelTestMsg_AnswerToLife::WriteReplyParams(reply_msg, 42); |
| 499 Send(reply_msg); | 502 Send(reply_msg); |
| 500 } | 503 } |
| 501 } | 504 } |
| 502 | 505 |
| 503 bool pump_during_send_, close_channel_; | 506 bool pump_during_send_, close_channel_; |
| 504 }; | 507 }; |
| 505 | 508 |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 TEST_F(IPCSyncChannelTest, SendWithTimeoutTimeout) { | 1014 TEST_F(IPCSyncChannelTest, SendWithTimeoutTimeout) { |
| 1012 SendWithTimeoutTimeout(false); | 1015 SendWithTimeoutTimeout(false); |
| 1013 SendWithTimeoutTimeout(true); | 1016 SendWithTimeoutTimeout(true); |
| 1014 } | 1017 } |
| 1015 | 1018 |
| 1016 // Sends some message that time-out and some that succeed. | 1019 // Sends some message that time-out and some that succeed. |
| 1017 TEST_F(IPCSyncChannelTest, SendWithTimeoutMixedOKAndTimeout) { | 1020 TEST_F(IPCSyncChannelTest, SendWithTimeoutMixedOKAndTimeout) { |
| 1018 SendWithTimeoutMixedOKAndTimeout(false); | 1021 SendWithTimeoutMixedOKAndTimeout(false); |
| 1019 SendWithTimeoutMixedOKAndTimeout(true); | 1022 SendWithTimeoutMixedOKAndTimeout(true); |
| 1020 } | 1023 } |
| OLD | NEW |