| 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/message_loop/message_loop.h" | |
| 12 #include "base/run_loop.h" | |
| 13 #include "base/test/simple_test_tick_clock.h" | 11 #include "base/test/simple_test_tick_clock.h" |
| 14 #include "media/cast/cast_config.h" | 12 #include "media/cast/cast_config.h" |
| 15 #include "media/cast/net/cast_transport_config.h" | 13 #include "media/cast/net/cast_transport_config.h" |
| 16 #include "media/cast/net/cast_transport_sender_impl.h" | 14 #include "media/cast/net/cast_transport_sender_impl.h" |
| 17 #include "media/cast/net/rtcp/rtcp.h" | 15 #include "media/cast/net/rtcp/rtcp.h" |
| 18 #include "media/cast/test/fake_single_thread_task_runner.h" | 16 #include "media/cast/test/fake_single_thread_task_runner.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 18 |
| 21 namespace media { | 19 namespace media { |
| 22 namespace cast { | 20 namespace cast { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 net::IPEndPoint(), | 61 net::IPEndPoint(), |
| 64 base::Bind(&UpdateCastTransportStatus), | 62 base::Bind(&UpdateCastTransportStatus), |
| 65 base::Bind(&CastTransportSenderImplTest::LogRawEvents, | 63 base::Bind(&CastTransportSenderImplTest::LogRawEvents, |
| 66 base::Unretained(this)), | 64 base::Unretained(this)), |
| 67 base::TimeDelta::FromMilliseconds(10), | 65 base::TimeDelta::FromMilliseconds(10), |
| 68 task_runner_, | 66 task_runner_, |
| 69 &transport_)); | 67 &transport_)); |
| 70 task_runner_->RunTasks(); | 68 task_runner_->RunTasks(); |
| 71 } | 69 } |
| 72 | 70 |
| 73 void LogRawEvents(const std::vector<PacketEvent>& packet_events) { | 71 void LogRawEvents(const std::vector<PacketEvent>& packet_events, |
| 72 const std::vector<FrameEvent>& frame_events) { |
| 74 num_times_callback_called_++; | 73 num_times_callback_called_++; |
| 75 if (num_times_callback_called_ == 3) { | |
| 76 run_loop_.Quit(); | |
| 77 } | |
| 78 } | 74 } |
| 79 | 75 |
| 80 static void UpdateCastTransportStatus(CastTransportStatus status) { | 76 static void UpdateCastTransportStatus(CastTransportStatus status) { |
| 81 } | 77 } |
| 82 | 78 |
| 83 base::SimpleTestTickClock testing_clock_; | 79 base::SimpleTestTickClock testing_clock_; |
| 84 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 80 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; |
| 85 scoped_ptr<CastTransportSenderImpl> transport_sender_; | 81 scoped_ptr<CastTransportSenderImpl> transport_sender_; |
| 86 FakePacketSender transport_; | 82 FakePacketSender transport_; |
| 87 base::MessageLoopForIO message_loop_; | |
| 88 base::RunLoop run_loop_; | |
| 89 int num_times_callback_called_; | 83 int num_times_callback_called_; |
| 90 }; | 84 }; |
| 91 | 85 |
| 92 TEST_F(CastTransportSenderImplTest, InitWithoutLogging) { | 86 TEST_F(CastTransportSenderImplTest, InitWithoutLogging) { |
| 93 InitWithoutLogging(); | 87 InitWithoutLogging(); |
| 94 message_loop_.PostDelayedTask(FROM_HERE, | 88 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(50)); |
| 95 run_loop_.QuitClosure(), | |
| 96 base::TimeDelta::FromMilliseconds(50)); | |
| 97 run_loop_.Run(); | |
| 98 EXPECT_EQ(0, num_times_callback_called_); | 89 EXPECT_EQ(0, num_times_callback_called_); |
| 99 } | 90 } |
| 100 | 91 |
| 101 TEST_F(CastTransportSenderImplTest, InitWithLogging) { | 92 TEST_F(CastTransportSenderImplTest, InitWithLogging) { |
| 102 InitWithLogging(); | 93 InitWithLogging(); |
| 103 message_loop_.PostDelayedTask(FROM_HERE, | 94 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(50)); |
| 104 run_loop_.QuitClosure(), | 95 EXPECT_EQ(5, num_times_callback_called_); |
| 105 base::TimeDelta::FromMilliseconds(50)); | |
| 106 run_loop_.Run(); | |
| 107 EXPECT_GT(num_times_callback_called_, 1); | |
| 108 } | 96 } |
| 109 | 97 |
| 110 } // namespace cast | 98 } // namespace cast |
| 111 } // namespace media | 99 } // namespace media |
| OLD | NEW |