| 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 #include "base/time.h" | 5 #include "base/time.h" |
| 6 #include "base/waitable_event.h" | 6 #include "base/waitable_event.h" |
| 7 #include "base/test/test_timeouts.h" | 7 #include "base/test/test_timeouts.h" |
| 8 #include "net/base/completion_callback.h" | 8 #include "net/base/completion_callback.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 namespace remoting { | 29 namespace remoting { |
| 30 namespace protocol { | 30 namespace protocol { |
| 31 class JingleSessionTest; | 31 class JingleSessionTest; |
| 32 } // namespace protocol | 32 } // namespace protocol |
| 33 } // namespace remoting | 33 } // namespace remoting |
| 34 | 34 |
| 35 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::protocol::JingleSessionTest); | 35 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::protocol::JingleSessionTest); |
| 36 | 36 |
| 37 namespace remoting { | 37 namespace remoting { |
| 38 | |
| 39 namespace protocol { | 38 namespace protocol { |
| 40 | 39 |
| 41 namespace { | 40 namespace { |
| 42 // Send 100 messages 1024 bytes each. UDP messages are sent with 10ms delay | 41 // Send 100 messages 1024 bytes each. UDP messages are sent with 10ms delay |
| 43 // between messages (about 1 second for 100 messages). | 42 // between messages (about 1 second for 100 messages). |
| 44 const int kMessageSize = 1024; | 43 const int kMessageSize = 1024; |
| 45 const int kMessages = 100; | 44 const int kMessages = 100; |
| 46 const int kTestDataSize = kMessages * kMessageSize; | 45 const int kTestDataSize = kMessages * kMessageSize; |
| 47 const int kUdpWriteDelayMs = 10; | 46 const int kUdpWriteDelayMs = 10; |
| 48 } // namespace | 47 } // namespace |
| (...skipping 13 matching lines...) Expand all Loading... |
| 62 class JingleSessionTest : public testing::Test { | 61 class JingleSessionTest : public testing::Test { |
| 63 public: | 62 public: |
| 64 // Helper method to copy to set value of client_connection_. | 63 // Helper method to copy to set value of client_connection_. |
| 65 void SetHostSession(Session* session) { | 64 void SetHostSession(Session* session) { |
| 66 DCHECK(session); | 65 DCHECK(session); |
| 67 host_session_ = session; | 66 host_session_ = session; |
| 68 host_session_->SetStateChangeCallback( | 67 host_session_->SetStateChangeCallback( |
| 69 NewCallback(&host_connection_callback_, | 68 NewCallback(&host_connection_callback_, |
| 70 &MockSessionCallback::OnStateChange)); | 69 &MockSessionCallback::OnStateChange)); |
| 71 | 70 |
| 72 session->set_config(ChromotocolConfig::CreateDefault()); | 71 session->set_config(SessionConfig::CreateDefault()); |
| 73 } | 72 } |
| 74 | 73 |
| 75 protected: | 74 protected: |
| 76 virtual void SetUp() { | 75 virtual void SetUp() { |
| 77 thread_.Start(); | 76 thread_.Start(); |
| 78 } | 77 } |
| 79 | 78 |
| 80 virtual void TearDown() { | 79 virtual void TearDown() { |
| 81 CloseSessions(); | 80 CloseSessions(); |
| 82 | 81 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 .Times(1) | 159 .Times(1) |
| 161 .WillOnce(InvokeWithoutArgs(&client_connected_event, | 160 .WillOnce(InvokeWithoutArgs(&client_connected_event, |
| 162 &base::WaitableEvent::Signal)); | 161 &base::WaitableEvent::Signal)); |
| 163 // Expect that the connection will be closed eventually. | 162 // Expect that the connection will be closed eventually. |
| 164 EXPECT_CALL(client_connection_callback_, | 163 EXPECT_CALL(client_connection_callback_, |
| 165 OnStateChange(Session::CLOSED)) | 164 OnStateChange(Session::CLOSED)) |
| 166 .Times(1); | 165 .Times(1); |
| 167 | 166 |
| 168 client_session_ = client_server_->Connect( | 167 client_session_ = client_server_->Connect( |
| 169 SessionManagerPair::kHostJid, | 168 SessionManagerPair::kHostJid, |
| 170 CandidateChromotocolConfig::CreateDefault(), | 169 CandidateSessionConfig::CreateDefault(), |
| 171 NewCallback(&client_connection_callback_, | 170 NewCallback(&client_connection_callback_, |
| 172 &MockSessionCallback::OnStateChange)); | 171 &MockSessionCallback::OnStateChange)); |
| 173 | 172 |
| 174 return host_connected_event.TimedWait(base::TimeDelta::FromMilliseconds( | 173 return host_connected_event.TimedWait(base::TimeDelta::FromMilliseconds( |
| 175 TestTimeouts::action_max_timeout_ms())) && | 174 TestTimeouts::action_max_timeout_ms())) && |
| 176 client_connected_event.TimedWait(base::TimeDelta::FromMilliseconds( | 175 client_connected_event.TimedWait(base::TimeDelta::FromMilliseconds( |
| 177 TestTimeouts::action_max_timeout_ms())); | 176 TestTimeouts::action_max_timeout_ms())); |
| 178 } | 177 } |
| 179 | 178 |
| 180 static void SignalEvent(base::WaitableEvent* event) { | 179 static void SignalEvent(base::WaitableEvent* event) { |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 EXPECT_CALL(client_connection_callback_, | 530 EXPECT_CALL(client_connection_callback_, |
| 532 OnStateChange(Session::CONNECTING)) | 531 OnStateChange(Session::CONNECTING)) |
| 533 .Times(1); | 532 .Times(1); |
| 534 EXPECT_CALL(client_connection_callback_, | 533 EXPECT_CALL(client_connection_callback_, |
| 535 OnStateChange(Session::CLOSED)) | 534 OnStateChange(Session::CLOSED)) |
| 536 .Times(1) | 535 .Times(1) |
| 537 .WillOnce(InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)); | 536 .WillOnce(InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)); |
| 538 | 537 |
| 539 client_session_ = client_server_->Connect( | 538 client_session_ = client_server_->Connect( |
| 540 SessionManagerPair::kHostJid, | 539 SessionManagerPair::kHostJid, |
| 541 CandidateChromotocolConfig::CreateDefault(), | 540 CandidateSessionConfig::CreateDefault(), |
| 542 NewCallback(&client_connection_callback_, | 541 NewCallback(&client_connection_callback_, |
| 543 &MockSessionCallback::OnStateChange)); | 542 &MockSessionCallback::OnStateChange)); |
| 544 | 543 |
| 545 ASSERT_TRUE( | 544 ASSERT_TRUE( |
| 546 done_event.TimedWait(base::TimeDelta::FromMilliseconds( | 545 done_event.TimedWait(base::TimeDelta::FromMilliseconds( |
| 547 TestTimeouts::action_max_timeout_ms()))); | 546 TestTimeouts::action_max_timeout_ms()))); |
| 548 } | 547 } |
| 549 | 548 |
| 550 // Verify that we can connect two endpoints. | 549 // Verify that we can connect two endpoints. |
| 551 TEST_F(JingleSessionTest, Connect) { | 550 TEST_F(JingleSessionTest, Connect) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 client_session_)); | 607 client_session_)); |
| 609 tester->Start(ChannelTesterBase::VIDEO_RTP); | 608 tester->Start(ChannelTesterBase::VIDEO_RTP); |
| 610 ASSERT_TRUE(tester->WaitFinished()); | 609 ASSERT_TRUE(tester->WaitFinished()); |
| 611 tester->CheckResults(); | 610 tester->CheckResults(); |
| 612 | 611 |
| 613 // Connections must be closed while |tester| still exists. | 612 // Connections must be closed while |tester| still exists. |
| 614 CloseSessions(); | 613 CloseSessions(); |
| 615 } | 614 } |
| 616 | 615 |
| 617 } // namespace protocol | 616 } // namespace protocol |
| 618 | |
| 619 } // namespace remoting | 617 } // namespace remoting |
| OLD | NEW |