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 "ipc/ipc_sync_channel.h" | 5 #include "ipc/ipc_sync_channel.h" |
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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 } | 294 } |
295 }; | 295 }; |
296 | 296 |
297 void Simple(bool pump_during_send) { | 297 void Simple(bool pump_during_send) { |
298 std::vector<Worker*> workers; | 298 std::vector<Worker*> workers; |
299 workers.push_back(new SimpleServer(pump_during_send)); | 299 workers.push_back(new SimpleServer(pump_during_send)); |
300 workers.push_back(new SimpleClient()); | 300 workers.push_back(new SimpleClient()); |
301 RunTest(workers); | 301 RunTest(workers); |
302 } | 302 } |
303 | 303 |
| 304 #if defined(OS_ANDROID) |
| 305 #define MAYBE_Simple DISABLED_Simple |
| 306 #else |
| 307 #define MAYBE_Simple Simple |
| 308 #endif |
304 // Tests basic synchronous call | 309 // Tests basic synchronous call |
305 TEST_F(IPCSyncChannelTest, Simple) { | 310 TEST_F(IPCSyncChannelTest, MAYBE_Simple) { |
306 Simple(false); | 311 Simple(false); |
307 Simple(true); | 312 Simple(true); |
308 } | 313 } |
309 | 314 |
310 //------------------------------------------------------------------------------ | 315 //------------------------------------------------------------------------------ |
311 | 316 |
312 // Worker classes which override how the sync channel is created to use the | 317 // Worker classes which override how the sync channel is created to use the |
313 // two-step initialization (calling the lightweight constructor and then | 318 // two-step initialization (calling the lightweight constructor and then |
314 // ChannelProxy::Init separately) process. | 319 // ChannelProxy::Init separately) process. |
315 class TwoStepServer : public Worker { | 320 class TwoStepServer : public Worker { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 // Tests that the caller unblocks to answer a sync message from the receiver. | 515 // Tests that the caller unblocks to answer a sync message from the receiver. |
511 TEST_F(IPCSyncChannelTest, Unblock) { | 516 TEST_F(IPCSyncChannelTest, Unblock) { |
512 Unblock(false, false, false); | 517 Unblock(false, false, false); |
513 Unblock(false, true, false); | 518 Unblock(false, true, false); |
514 Unblock(true, false, false); | 519 Unblock(true, false, false); |
515 Unblock(true, true, false); | 520 Unblock(true, true, false); |
516 } | 521 } |
517 | 522 |
518 //------------------------------------------------------------------------------ | 523 //------------------------------------------------------------------------------ |
519 | 524 |
| 525 #if defined(OS_ANDROID) |
| 526 #define MAYBE_ChannelDeleteDuringSend DISABLED_ChannelDeleteDuringSend |
| 527 #else |
| 528 #define MAYBE_ChannelDeleteDuringSend ChannelDeleteDuringSend |
| 529 #endif |
520 // Tests that the the SyncChannel object can be deleted during a Send. | 530 // Tests that the the SyncChannel object can be deleted during a Send. |
521 TEST_F(IPCSyncChannelTest, ChannelDeleteDuringSend) { | 531 TEST_F(IPCSyncChannelTest, MAYBE_ChannelDeleteDuringSend) { |
522 Unblock(false, false, true); | 532 Unblock(false, false, true); |
523 Unblock(false, true, true); | 533 Unblock(false, true, true); |
524 Unblock(true, false, true); | 534 Unblock(true, false, true); |
525 Unblock(true, true, true); | 535 Unblock(true, true, true); |
526 } | 536 } |
527 | 537 |
528 //------------------------------------------------------------------------------ | 538 //------------------------------------------------------------------------------ |
529 | 539 |
530 class RecursiveServer : public Worker { | 540 class RecursiveServer : public Worker { |
531 public: | 541 public: |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 } | 871 } |
862 }; | 872 }; |
863 | 873 |
864 void ChattyServer(bool pump_during_send) { | 874 void ChattyServer(bool pump_during_send) { |
865 std::vector<Worker*> workers; | 875 std::vector<Worker*> workers; |
866 workers.push_back(new UnblockServer(pump_during_send, false)); | 876 workers.push_back(new UnblockServer(pump_during_send, false)); |
867 workers.push_back(new ChattyClient()); | 877 workers.push_back(new ChattyClient()); |
868 RunTest(workers); | 878 RunTest(workers); |
869 } | 879 } |
870 | 880 |
| 881 #if defined(OS_ANDROID) |
| 882 // Times out. |
| 883 #define MAYBE_ChattyServer DISABLED_ChattyServer |
| 884 #else |
| 885 #define MAYBE_ChattyServer ChattyServer |
| 886 #endif |
871 // Tests http://b/1093251 - that sending lots of sync messages while | 887 // Tests http://b/1093251 - that sending lots of sync messages while |
872 // the receiver is waiting for a sync reply does not overflow the PostMessage | 888 // the receiver is waiting for a sync reply does not overflow the PostMessage |
873 // queue. | 889 // queue. |
874 TEST_F(IPCSyncChannelTest, ChattyServer) { | 890 TEST_F(IPCSyncChannelTest, MAYBE_ChattyServer) { |
875 ChattyServer(false); | 891 ChattyServer(false); |
876 ChattyServer(true); | 892 ChattyServer(true); |
877 } | 893 } |
878 | 894 |
879 //------------------------------------------------------------------------------ | 895 //------------------------------------------------------------------------------ |
880 | 896 |
881 void NestedCallback(Worker* server) { | 897 void NestedCallback(Worker* server) { |
882 // Sleep a bit so that we wake up after the reply has been received. | 898 // Sleep a bit so that we wake up after the reply has been received. |
883 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(250)); | 899 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(250)); |
884 server->SendAnswerToLife(true, true); | 900 server->SendAnswerToLife(true, true); |
(...skipping 19 matching lines...) Expand all Loading... |
904 // Even though we have a timeout on the Send, it will succeed since for this | 920 // Even though we have a timeout on the Send, it will succeed since for this |
905 // bug, the reply message comes back and is deserialized, however the done | 921 // bug, the reply message comes back and is deserialized, however the done |
906 // event wasn't set. So we indirectly use the timeout task to notice if a | 922 // event wasn't set. So we indirectly use the timeout task to notice if a |
907 // timeout occurred. | 923 // timeout occurred. |
908 SendAnswerToLife(true, true); | 924 SendAnswerToLife(true, true); |
909 DCHECK(!timeout_occurred); | 925 DCHECK(!timeout_occurred); |
910 Done(); | 926 Done(); |
911 } | 927 } |
912 }; | 928 }; |
913 | 929 |
| 930 #if defined(OS_ANDROID) |
| 931 #define MAYBE_DoneEventRace DISABLED_DoneEventRace |
| 932 #else |
| 933 #define MAYBE_DoneEventRace DoneEventRace |
| 934 #endif |
914 // Tests http://b/1474092 - that if after the done_event is set but before | 935 // Tests http://b/1474092 - that if after the done_event is set but before |
915 // OnObjectSignaled is called another message is sent out, then after its | 936 // OnObjectSignaled is called another message is sent out, then after its |
916 // reply comes back OnObjectSignaled will be called for the first message. | 937 // reply comes back OnObjectSignaled will be called for the first message. |
917 TEST_F(IPCSyncChannelTest, DoneEventRace) { | 938 TEST_F(IPCSyncChannelTest, MAYBE_DoneEventRace) { |
918 std::vector<Worker*> workers; | 939 std::vector<Worker*> workers; |
919 workers.push_back(new DoneEventRaceServer()); | 940 workers.push_back(new DoneEventRaceServer()); |
920 workers.push_back(new SimpleClient()); | 941 workers.push_back(new SimpleClient()); |
921 RunTest(workers); | 942 RunTest(workers); |
922 } | 943 } |
923 | 944 |
924 //------------------------------------------------------------------------------ | 945 //------------------------------------------------------------------------------ |
925 | 946 |
926 class TestSyncMessageFilter : public SyncMessageFilter { | 947 class TestSyncMessageFilter : public SyncMessageFilter { |
927 public: | 948 public: |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 } | 1577 } |
1557 | 1578 |
1558 scoped_ptr<SyncChannel> other_channel_; | 1579 scoped_ptr<SyncChannel> other_channel_; |
1559 WaitableEvent* event1_; | 1580 WaitableEvent* event1_; |
1560 WaitableEvent* event2_; | 1581 WaitableEvent* event2_; |
1561 std::string other_channel_name_; | 1582 std::string other_channel_name_; |
1562 int group_; | 1583 int group_; |
1563 int* success_; | 1584 int* success_; |
1564 }; | 1585 }; |
1565 | 1586 |
1566 TEST_F(IPCSyncChannelTest, RestrictedDispatch4WayDeadlock) { | 1587 #if defined(OS_ANDROID) |
| 1588 #define MAYBE_RestrictedDispatch4WayDeadlock \ |
| 1589 DISABLED_RestrictedDispatch4WayDeadlock |
| 1590 #else |
| 1591 #define MAYBE_RestrictedDispatch4WayDeadlock RestrictedDispatch4WayDeadlock |
| 1592 #endif |
| 1593 TEST_F(IPCSyncChannelTest, MAYBE_RestrictedDispatch4WayDeadlock) { |
1567 int success = 0; | 1594 int success = 0; |
1568 std::vector<Worker*> workers; | 1595 std::vector<Worker*> workers; |
1569 WaitableEvent event0(true, false); | 1596 WaitableEvent event0(true, false); |
1570 WaitableEvent event1(true, false); | 1597 WaitableEvent event1(true, false); |
1571 WaitableEvent event2(true, false); | 1598 WaitableEvent event2(true, false); |
1572 WaitableEvent event3(true, false); | 1599 WaitableEvent event3(true, false); |
1573 workers.push_back(new RestrictedDispatchPipeWorker( | 1600 workers.push_back(new RestrictedDispatchPipeWorker( |
1574 "channel0", &event0, "channel1", &event1, 1, &success)); | 1601 "channel0", &event0, "channel1", &event1, 1, &success)); |
1575 workers.push_back(new RestrictedDispatchPipeWorker( | 1602 workers.push_back(new RestrictedDispatchPipeWorker( |
1576 "channel1", &event1, "channel2", &event2, 2, NULL)); | 1603 "channel1", &event1, "channel2", &event2, 2, NULL)); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 } | 1800 } |
1774 | 1801 |
1775 // Windows needs to send an out-of-band secret to verify the client end of the | 1802 // Windows needs to send an out-of-band secret to verify the client end of the |
1776 // channel. Test that we still connect correctly in that case. | 1803 // channel. Test that we still connect correctly in that case. |
1777 TEST_F(IPCSyncChannelTest, Verified) { | 1804 TEST_F(IPCSyncChannelTest, Verified) { |
1778 Verified(); | 1805 Verified(); |
1779 } | 1806 } |
1780 | 1807 |
1781 } // namespace | 1808 } // namespace |
1782 } // namespace IPC | 1809 } // namespace IPC |
OLD | NEW |