| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 public: | 701 public: |
| 702 QueuedReplyServer(base::Thread* listener_thread, | 702 QueuedReplyServer(base::Thread* listener_thread, |
| 703 const std::string& channel_name, | 703 const std::string& channel_name, |
| 704 const std::string& reply_text) | 704 const std::string& reply_text) |
| 705 : Worker(channel_name, Channel::MODE_SERVER), | 705 : Worker(channel_name, Channel::MODE_SERVER), |
| 706 reply_text_(reply_text) { | 706 reply_text_(reply_text) { |
| 707 Worker::OverrideThread(listener_thread); | 707 Worker::OverrideThread(listener_thread); |
| 708 } | 708 } |
| 709 | 709 |
| 710 virtual void OnNestedTestMsg(Message* reply_msg) { | 710 virtual void OnNestedTestMsg(Message* reply_msg) { |
| 711 LOG(INFO) << __FUNCTION__ << " Sending reply: " | 711 VLOG(1) << __FUNCTION__ << " Sending reply: " << reply_text_; |
| 712 << reply_text_.c_str(); | 712 SyncChannelNestedTestMsg_String::WriteReplyParams(reply_msg, reply_text_); |
| 713 SyncChannelNestedTestMsg_String::WriteReplyParams( | |
| 714 reply_msg, reply_text_); | |
| 715 Send(reply_msg); | 713 Send(reply_msg); |
| 716 Done(); | 714 Done(); |
| 717 } | 715 } |
| 718 | 716 |
| 719 private: | 717 private: |
| 720 std::string reply_text_; | 718 std::string reply_text_; |
| 721 }; | 719 }; |
| 722 | 720 |
| 723 // The QueuedReplyClient class provides functionality to test the case where | 721 // The QueuedReplyClient class provides functionality to test the case where |
| 724 // multiple sync channels are in use on the same thread and they make nested | 722 // multiple sync channels are in use on the same thread and they make nested |
| (...skipping 15 matching lines...) Expand all Loading... |
| 740 | 738 |
| 741 virtual void Run() { | 739 virtual void Run() { |
| 742 std::string response; | 740 std::string response; |
| 743 SyncMessage* msg = new SyncChannelNestedTestMsg_String(&response); | 741 SyncMessage* msg = new SyncChannelNestedTestMsg_String(&response); |
| 744 if (pump_during_send_) | 742 if (pump_during_send_) |
| 745 msg->EnableMessagePumping(); | 743 msg->EnableMessagePumping(); |
| 746 bool result = Send(msg); | 744 bool result = Send(msg); |
| 747 DCHECK(result); | 745 DCHECK(result); |
| 748 DCHECK_EQ(response, expected_text_); | 746 DCHECK_EQ(response, expected_text_); |
| 749 | 747 |
| 750 LOG(INFO) << __FUNCTION__ << " Received reply: " | 748 VLOG(1) << __FUNCTION__ << " Received reply: " << response; |
| 751 << response.c_str(); | |
| 752 Done(); | 749 Done(); |
| 753 } | 750 } |
| 754 | 751 |
| 755 private: | 752 private: |
| 756 bool pump_during_send_; | 753 bool pump_during_send_; |
| 757 std::string expected_text_; | 754 std::string expected_text_; |
| 758 }; | 755 }; |
| 759 | 756 |
| 760 void QueuedReply(bool client_pump) { | 757 void QueuedReply(bool client_pump) { |
| 761 std::vector<Worker*> workers; | 758 std::vector<Worker*> workers; |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 server.done_event()->Wait(); | 1161 server.done_event()->Wait(); |
| 1165 server.done_event()->Reset(); | 1162 server.done_event()->Reset(); |
| 1166 | 1163 |
| 1167 server.SendDummy(); | 1164 server.SendDummy(); |
| 1168 server.done_event()->Wait(); | 1165 server.done_event()->Wait(); |
| 1169 | 1166 |
| 1170 EXPECT_FALSE(server.send_result()); | 1167 EXPECT_FALSE(server.send_result()); |
| 1171 } | 1168 } |
| 1172 | 1169 |
| 1173 | 1170 |
| OLD | NEW |