OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 buzz::XmppReturnStatus result = FakeXmppClient::SendStanza(stanza); | 67 buzz::XmppReturnStatus result = FakeXmppClient::SendStanza(stanza); |
68 if (test->respond_to_pings && (stanza->FirstNamed(buzz::QN_PING) != NULL)) { | 68 if (test->respond_to_pings && (stanza->FirstNamed(buzz::QN_PING) != NULL)) { |
69 std::string ping_response = | 69 std::string ping_response = |
70 "<iq xmlns=\'jabber:client\' id='0' type='result'/>"; | 70 "<iq xmlns=\'jabber:client\' id='0' type='result'/>"; |
71 HandleStanza(buzz::XmlElement::ForStr(ping_response)); | 71 HandleStanza(buzz::XmlElement::ForStr(ping_response)); |
72 } | 72 } |
73 return result; | 73 return result; |
74 } | 74 } |
75 | 75 |
76 TEST_F(PingTaskTest, TestSuccess) { | 76 TEST_F(PingTaskTest, TestSuccess) { |
77 uint32 ping_period_millis = 100; | 77 uint32_t ping_period_millis = 100; |
78 buzz::PingTask* task = new buzz::PingTask(xmpp_client, | 78 buzz::PingTask* task = new buzz::PingTask(xmpp_client, |
79 rtc::Thread::Current(), | 79 rtc::Thread::Current(), |
80 ping_period_millis, ping_period_millis / 10); | 80 ping_period_millis, ping_period_millis / 10); |
81 ConnectTimeoutSignal(task); | 81 ConnectTimeoutSignal(task); |
82 task->Start(); | 82 task->Start(); |
83 unsigned int expected_ping_count = 5U; | 83 unsigned int expected_ping_count = 5U; |
84 EXPECT_EQ_WAIT(xmpp_client->sent_stanzas().size(), expected_ping_count, | 84 EXPECT_EQ_WAIT(xmpp_client->sent_stanzas().size(), expected_ping_count, |
85 ping_period_millis * (expected_ping_count + 1)); | 85 ping_period_millis * (expected_ping_count + 1)); |
86 EXPECT_FALSE(task->IsDone()); | 86 EXPECT_FALSE(task->IsDone()); |
87 EXPECT_FALSE(timed_out); | 87 EXPECT_FALSE(timed_out); |
88 } | 88 } |
89 | 89 |
90 TEST_F(PingTaskTest, TestTimeout) { | 90 TEST_F(PingTaskTest, TestTimeout) { |
91 respond_to_pings = false; | 91 respond_to_pings = false; |
92 uint32 ping_timeout_millis = 200; | 92 uint32_t ping_timeout_millis = 200; |
93 buzz::PingTask* task = new buzz::PingTask(xmpp_client, | 93 buzz::PingTask* task = new buzz::PingTask(xmpp_client, |
94 rtc::Thread::Current(), | 94 rtc::Thread::Current(), |
95 ping_timeout_millis * 10, ping_timeout_millis); | 95 ping_timeout_millis * 10, ping_timeout_millis); |
96 ConnectTimeoutSignal(task); | 96 ConnectTimeoutSignal(task); |
97 task->Start(); | 97 task->Start(); |
98 WAIT(false, ping_timeout_millis / 2); | 98 WAIT(false, ping_timeout_millis / 2); |
99 EXPECT_FALSE(timed_out); | 99 EXPECT_FALSE(timed_out); |
100 EXPECT_TRUE_WAIT(timed_out, ping_timeout_millis * 2); | 100 EXPECT_TRUE_WAIT(timed_out, ping_timeout_millis * 2); |
101 } | 101 } |
OLD | NEW |