| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <gtest/gtest.h> | 5 #include <gtest/gtest.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/test/simple_test_tick_clock.h" | 11 #include "base/test/simple_test_tick_clock.h" |
| 12 #include "base/values.h" |
| 12 #include "media/cast/cast_config.h" | 13 #include "media/cast/cast_config.h" |
| 13 #include "media/cast/net/cast_transport_config.h" | 14 #include "media/cast/net/cast_transport_config.h" |
| 14 #include "media/cast/net/cast_transport_sender_impl.h" | 15 #include "media/cast/net/cast_transport_sender_impl.h" |
| 15 #include "media/cast/net/rtcp/rtcp.h" | 16 #include "media/cast/net/rtcp/rtcp.h" |
| 16 #include "media/cast/test/fake_single_thread_task_runner.h" | 17 #include "media/cast/test/fake_single_thread_task_runner.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace media { | 20 namespace media { |
| 20 namespace cast { | 21 namespace cast { |
| 21 | 22 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 net::IPEndPoint(), | 84 net::IPEndPoint(), |
| 84 make_scoped_ptr(new base::DictionaryValue), | 85 make_scoped_ptr(new base::DictionaryValue), |
| 85 base::Bind(&UpdateCastTransportStatus), | 86 base::Bind(&UpdateCastTransportStatus), |
| 86 BulkRawEventsCallback(), | 87 BulkRawEventsCallback(), |
| 87 base::TimeDelta(), | 88 base::TimeDelta(), |
| 88 task_runner_, | 89 task_runner_, |
| 89 &transport_)); | 90 &transport_)); |
| 90 task_runner_->RunTasks(); | 91 task_runner_->RunTasks(); |
| 91 } | 92 } |
| 92 | 93 |
| 94 void InitWithOptions() { |
| 95 scoped_ptr<base::DictionaryValue> options( |
| 96 new base::DictionaryValue); |
| 97 options->SetBoolean("DHCP", true); |
| 98 options->SetBoolean("disable_wifi_scan", true); |
| 99 options->SetBoolean("media_streaming_mode", true); |
| 100 options->SetInteger("pacer_target_burst_size", 20); |
| 101 options->SetInteger("pacer_max_burst_size", 100); |
| 102 transport_sender_.reset( |
| 103 new CastTransportSenderImpl(NULL, |
| 104 &testing_clock_, |
| 105 net::IPEndPoint(), |
| 106 options.Pass(), |
| 107 base::Bind(&UpdateCastTransportStatus), |
| 108 BulkRawEventsCallback(), |
| 109 base::TimeDelta(), |
| 110 task_runner_, |
| 111 &transport_)); |
| 112 task_runner_->RunTasks(); |
| 113 } |
| 114 |
| 93 void InitWithLogging() { | 115 void InitWithLogging() { |
| 94 transport_sender_.reset(new CastTransportSenderImpl( | 116 transport_sender_.reset(new CastTransportSenderImpl( |
| 95 NULL, | 117 NULL, |
| 96 &testing_clock_, | 118 &testing_clock_, |
| 97 net::IPEndPoint(), | 119 net::IPEndPoint(), |
| 98 make_scoped_ptr(new base::DictionaryValue), | 120 make_scoped_ptr(new base::DictionaryValue), |
| 99 base::Bind(&UpdateCastTransportStatus), | 121 base::Bind(&UpdateCastTransportStatus), |
| 100 base::Bind(&CastTransportSenderImplTest::LogRawEvents, | 122 base::Bind(&CastTransportSenderImplTest::LogRawEvents, |
| 101 base::Unretained(this)), | 123 base::Unretained(this)), |
| 102 base::TimeDelta::FromMilliseconds(10), | 124 base::TimeDelta::FromMilliseconds(10), |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(50)); | 169 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(50)); |
| 148 EXPECT_EQ(0, num_times_callback_called_); | 170 EXPECT_EQ(0, num_times_callback_called_); |
| 149 } | 171 } |
| 150 | 172 |
| 151 TEST_F(CastTransportSenderImplTest, InitWithLogging) { | 173 TEST_F(CastTransportSenderImplTest, InitWithLogging) { |
| 152 InitWithLogging(); | 174 InitWithLogging(); |
| 153 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(50)); | 175 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(50)); |
| 154 EXPECT_EQ(5, num_times_callback_called_); | 176 EXPECT_EQ(5, num_times_callback_called_); |
| 155 } | 177 } |
| 156 | 178 |
| 179 TEST_F(CastTransportSenderImplTest, InitWithOptions) { |
| 180 InitWithOptions(); |
| 181 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(50)); |
| 182 EXPECT_EQ(0, num_times_callback_called_); |
| 183 } |
| 184 |
| 157 TEST_F(CastTransportSenderImplTest, NacksCancelRetransmits) { | 185 TEST_F(CastTransportSenderImplTest, NacksCancelRetransmits) { |
| 158 InitWithoutLogging(); | 186 InitWithoutLogging(); |
| 159 InitializeVideo(); | 187 InitializeVideo(); |
| 160 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(50)); | 188 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(50)); |
| 161 | 189 |
| 162 // A fake frame that will be decomposed into 4 packets. | 190 // A fake frame that will be decomposed into 4 packets. |
| 163 EncodedFrame fake_frame; | 191 EncodedFrame fake_frame; |
| 164 fake_frame.frame_id = 1; | 192 fake_frame.frame_id = 1; |
| 165 fake_frame.rtp_timestamp = 1; | 193 fake_frame.rtp_timestamp = 1; |
| 166 fake_frame.dependency = EncodedFrame::KEY; | 194 fake_frame.dependency = EncodedFrame::KEY; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(2)); | 371 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(2)); |
| 344 transport_sender_->OnReceivedCastMessage(kVideoSsrc, | 372 transport_sender_->OnReceivedCastMessage(kVideoSsrc, |
| 345 RtcpCastMessageCallback(), | 373 RtcpCastMessageCallback(), |
| 346 cast_message); | 374 cast_message); |
| 347 task_runner_->RunTasks(); | 375 task_runner_->RunTasks(); |
| 348 EXPECT_EQ(7, transport_.packets_sent()); | 376 EXPECT_EQ(7, transport_.packets_sent()); |
| 349 } | 377 } |
| 350 | 378 |
| 351 } // namespace cast | 379 } // namespace cast |
| 352 } // namespace media | 380 } // namespace media |
| OLD | NEW |