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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 // pumps messages while waiting for a response. | 801 // pumps messages while waiting for a response. |
802 TEST_F(IPCSyncChannelTest, QueuedReply) { | 802 TEST_F(IPCSyncChannelTest, QueuedReply) { |
803 QueuedReply(false); | 803 QueuedReply(false); |
804 QueuedReply(true); | 804 QueuedReply(true); |
805 } | 805 } |
806 | 806 |
807 //----------------------------------------------------------------------------- | 807 //----------------------------------------------------------------------------- |
808 | 808 |
809 namespace { | 809 namespace { |
810 | 810 |
| 811 void DropAssert(const std::string&) {} |
| 812 |
811 class BadServer : public Worker { | 813 class BadServer : public Worker { |
812 public: | 814 public: |
813 explicit BadServer(bool pump_during_send) | 815 explicit BadServer(bool pump_during_send) |
814 : Worker(Channel::MODE_SERVER, "simpler_server"), | 816 : Worker(Channel::MODE_SERVER, "simpler_server"), |
815 pump_during_send_(pump_during_send) { } | 817 pump_during_send_(pump_during_send) { } |
816 void Run() { | 818 void Run() { |
817 int answer = 0; | 819 int answer = 0; |
818 | 820 |
819 SyncMessage* msg = new SyncMessage( | 821 SyncMessage* msg = new SyncMessage( |
820 MSG_ROUTING_CONTROL, SyncChannelTestMsg_Double::ID, | 822 MSG_ROUTING_CONTROL, SyncChannelTestMsg_Double::ID, |
821 Message::PRIORITY_NORMAL, NULL); | 823 Message::PRIORITY_NORMAL, NULL); |
822 if (pump_during_send_) | 824 if (pump_during_send_) |
823 msg->EnableMessagePumping(); | 825 msg->EnableMessagePumping(); |
824 | 826 |
825 // Temporarily set the minimum logging very high so that the assertion | 827 // Temporarily ignore asserts so that the assertion in |
826 // in ipc_message_utils doesn't fire. | 828 // ipc_message_utils doesn't cause termination. |
827 int log_level = logging::GetMinLogLevel(); | 829 logging::SetLogAssertHandler(&DropAssert); |
828 logging::SetMinLogLevel(kint32max); | |
829 bool result = Send(msg); | 830 bool result = Send(msg); |
830 logging::SetMinLogLevel(log_level); | 831 logging::SetLogAssertHandler(NULL); |
831 DCHECK(!result); | 832 DCHECK(!result); |
832 | 833 |
833 // Need to send another message to get the client to call Done(). | 834 // Need to send another message to get the client to call Done(). |
834 result = Send(new SyncChannelTestMsg_AnswerToLife(&answer)); | 835 result = Send(new SyncChannelTestMsg_AnswerToLife(&answer)); |
835 DCHECK(result); | 836 DCHECK(result); |
836 DCHECK_EQ(answer, 42); | 837 DCHECK_EQ(answer, 42); |
837 | 838 |
838 Done(); | 839 Done(); |
839 } | 840 } |
840 | 841 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 server.done_event()->Wait(); | 1162 server.done_event()->Wait(); |
1162 server.done_event()->Reset(); | 1163 server.done_event()->Reset(); |
1163 | 1164 |
1164 server.SendDummy(); | 1165 server.SendDummy(); |
1165 server.done_event()->Wait(); | 1166 server.done_event()->Wait(); |
1166 | 1167 |
1167 EXPECT_FALSE(server.send_result()); | 1168 EXPECT_FALSE(server.send_result()); |
1168 } | 1169 } |
1169 | 1170 |
1170 | 1171 |
OLD | NEW |