Index: webrtc/video/payload_router_unittest.cc |
diff --git a/webrtc/video/payload_router_unittest.cc b/webrtc/video/payload_router_unittest.cc |
index 5b3dc9340a59be459bb2336aa7c65fba7e783017..c5d3f3865fdd1303fb7a54cf25cf50c8e0b748d0 100644 |
--- a/webrtc/video/payload_router_unittest.cc |
+++ b/webrtc/video/payload_router_unittest.cc |
@@ -23,20 +23,12 @@ using ::testing::Return; |
namespace webrtc { |
-class PayloadRouterTest : public ::testing::Test { |
- protected: |
- virtual void SetUp() { |
- payload_router_.reset(new PayloadRouter()); |
- } |
- std::unique_ptr<PayloadRouter> payload_router_; |
-}; |
- |
-TEST_F(PayloadRouterTest, SendOnOneModule) { |
+TEST(PayloadRouterTest, SendOnOneModule) { |
MockRtpRtcp rtp; |
std::vector<RtpRtcp*> modules(1, &rtp); |
- payload_router_->Init(modules); |
- payload_router_->SetSendingRtpModules(modules.size()); |
+ PayloadRouter payload_router(modules); |
+ payload_router.SetSendingRtpModules(modules.size()); |
uint8_t payload = 'a'; |
FrameType frame_type = kVideoFrameKey; |
@@ -45,47 +37,47 @@ TEST_F(PayloadRouterTest, SendOnOneModule) { |
EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, |
nullptr, nullptr)) |
.Times(0); |
- EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, |
- &payload, 1, nullptr, nullptr)); |
+ EXPECT_FALSE(payload_router.RoutePayload(frame_type, payload_type, 0, 0, |
+ &payload, 1, nullptr, nullptr)); |
- payload_router_->set_active(true); |
+ payload_router.set_active(true); |
EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, |
nullptr, nullptr)) |
.Times(1); |
- EXPECT_TRUE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, |
- &payload, 1, nullptr, nullptr)); |
+ EXPECT_TRUE(payload_router.RoutePayload(frame_type, payload_type, 0, 0, |
+ &payload, 1, nullptr, nullptr)); |
- payload_router_->set_active(false); |
+ payload_router.set_active(false); |
EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, |
nullptr, nullptr)) |
.Times(0); |
- EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, |
- &payload, 1, nullptr, nullptr)); |
+ EXPECT_FALSE(payload_router.RoutePayload(frame_type, payload_type, 0, 0, |
+ &payload, 1, nullptr, nullptr)); |
- payload_router_->set_active(true); |
+ payload_router.set_active(true); |
EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, |
nullptr, nullptr)) |
.Times(1); |
- EXPECT_TRUE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, |
- &payload, 1, nullptr, nullptr)); |
+ EXPECT_TRUE(payload_router.RoutePayload(frame_type, payload_type, 0, 0, |
+ &payload, 1, nullptr, nullptr)); |
- payload_router_->SetSendingRtpModules(0); |
+ payload_router.SetSendingRtpModules(0); |
EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, |
nullptr, nullptr)) |
.Times(0); |
- EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, |
- &payload, 1, nullptr, nullptr)); |
+ EXPECT_FALSE(payload_router.RoutePayload(frame_type, payload_type, 0, 0, |
+ &payload, 1, nullptr, nullptr)); |
} |
-TEST_F(PayloadRouterTest, SendSimulcast) { |
+TEST(PayloadRouterTest, SendSimulcast) { |
MockRtpRtcp rtp_1; |
MockRtpRtcp rtp_2; |
std::vector<RtpRtcp*> modules; |
modules.push_back(&rtp_1); |
modules.push_back(&rtp_2); |
- payload_router_->Init(modules); |
- payload_router_->SetSendingRtpModules(modules.size()); |
+ PayloadRouter payload_router(modules); |
+ payload_router.SetSendingRtpModules(modules.size()); |
uint8_t payload_1 = 'a'; |
FrameType frame_type_1 = kVideoFrameKey; |
@@ -93,14 +85,14 @@ TEST_F(PayloadRouterTest, SendSimulcast) { |
RTPVideoHeader rtp_hdr_1; |
rtp_hdr_1.simulcastIdx = 0; |
- payload_router_->set_active(true); |
+ payload_router.set_active(true); |
EXPECT_CALL(rtp_1, SendOutgoingData(frame_type_1, payload_type_1, 0, 0, _, 1, |
nullptr, &rtp_hdr_1)) |
.Times(1); |
EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) |
.Times(0); |
- EXPECT_TRUE(payload_router_->RoutePayload( |
- frame_type_1, payload_type_1, 0, 0, &payload_1, 1, nullptr, &rtp_hdr_1)); |
+ EXPECT_TRUE(payload_router.RoutePayload(frame_type_1, payload_type_1, 0, 0, |
+ &payload_1, 1, nullptr, &rtp_hdr_1)); |
uint8_t payload_2 = 'b'; |
FrameType frame_type_2 = kVideoFrameDelta; |
@@ -112,46 +104,45 @@ TEST_F(PayloadRouterTest, SendSimulcast) { |
.Times(1); |
EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) |
.Times(0); |
- EXPECT_TRUE(payload_router_->RoutePayload( |
- frame_type_2, payload_type_2, 0, 0, &payload_2, 1, nullptr, &rtp_hdr_2)); |
+ EXPECT_TRUE(payload_router.RoutePayload(frame_type_2, payload_type_2, 0, 0, |
+ &payload_2, 1, nullptr, &rtp_hdr_2)); |
// Inactive. |
- payload_router_->set_active(false); |
+ payload_router.set_active(false); |
EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) |
.Times(0); |
EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) |
.Times(0); |
- EXPECT_FALSE(payload_router_->RoutePayload( |
- frame_type_1, payload_type_1, 0, 0, &payload_1, 1, nullptr, &rtp_hdr_1)); |
- EXPECT_FALSE(payload_router_->RoutePayload( |
- frame_type_2, payload_type_2, 0, 0, &payload_2, 1, nullptr, &rtp_hdr_2)); |
+ EXPECT_FALSE(payload_router.RoutePayload(frame_type_1, payload_type_1, 0, 0, |
+ &payload_1, 1, nullptr, &rtp_hdr_1)); |
+ EXPECT_FALSE(payload_router.RoutePayload(frame_type_2, payload_type_2, 0, 0, |
+ &payload_2, 1, nullptr, &rtp_hdr_2)); |
// Invalid simulcast index. |
- payload_router_->SetSendingRtpModules(1); |
- payload_router_->set_active(true); |
+ payload_router.SetSendingRtpModules(1); |
+ payload_router.set_active(true); |
EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) |
.Times(0); |
EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) |
.Times(0); |
rtp_hdr_1.simulcastIdx = 1; |
- EXPECT_FALSE(payload_router_->RoutePayload( |
- frame_type_1, payload_type_1, 0, 0, &payload_1, 1, nullptr, &rtp_hdr_1)); |
+ EXPECT_FALSE(payload_router.RoutePayload(frame_type_1, payload_type_1, 0, 0, |
+ &payload_1, 1, nullptr, &rtp_hdr_1)); |
} |
-TEST_F(PayloadRouterTest, MaxPayloadLength) { |
+TEST(PayloadRouterTest, MaxPayloadLength) { |
// Without any limitations from the modules, verify we get the max payload |
// length for IP/UDP/SRTP with a MTU of 150 bytes. |
const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; |
- EXPECT_EQ(kDefaultMaxLength, payload_router_->DefaultMaxPayloadLength()); |
- EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength()); |
- |
MockRtpRtcp rtp_1; |
MockRtpRtcp rtp_2; |
std::vector<RtpRtcp*> modules; |
modules.push_back(&rtp_1); |
modules.push_back(&rtp_2); |
- payload_router_->Init(modules); |
- payload_router_->SetSendingRtpModules(modules.size()); |
+ PayloadRouter payload_router(modules); |
+ |
+ EXPECT_EQ(kDefaultMaxLength, PayloadRouter::DefaultMaxPayloadLength()); |
+ payload_router.SetSendingRtpModules(modules.size()); |
// Modules return a higher length than the default value. |
EXPECT_CALL(rtp_1, MaxDataPayloadLength()) |
@@ -160,7 +151,7 @@ TEST_F(PayloadRouterTest, MaxPayloadLength) { |
EXPECT_CALL(rtp_2, MaxDataPayloadLength()) |
.Times(1) |
.WillOnce(Return(kDefaultMaxLength + 10)); |
- EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength()); |
+ EXPECT_EQ(kDefaultMaxLength, payload_router.MaxPayloadLength()); |
// The modules return a value lower than default. |
const size_t kTestMinPayloadLength = 1001; |
@@ -170,17 +161,17 @@ TEST_F(PayloadRouterTest, MaxPayloadLength) { |
EXPECT_CALL(rtp_2, MaxDataPayloadLength()) |
.Times(1) |
.WillOnce(Return(kTestMinPayloadLength)); |
- EXPECT_EQ(kTestMinPayloadLength, payload_router_->MaxPayloadLength()); |
+ EXPECT_EQ(kTestMinPayloadLength, payload_router.MaxPayloadLength()); |
} |
-TEST_F(PayloadRouterTest, SetTargetSendBitrates) { |
+TEST(PayloadRouterTest, SetTargetSendBitrates) { |
MockRtpRtcp rtp_1; |
MockRtpRtcp rtp_2; |
std::vector<RtpRtcp*> modules; |
modules.push_back(&rtp_1); |
modules.push_back(&rtp_2); |
- payload_router_->Init(modules); |
- payload_router_->SetSendingRtpModules(modules.size()); |
+ PayloadRouter payload_router(modules); |
+ payload_router.SetSendingRtpModules(modules.size()); |
const uint32_t bitrate_1 = 10000; |
const uint32_t bitrate_2 = 76543; |
@@ -190,13 +181,13 @@ TEST_F(PayloadRouterTest, SetTargetSendBitrates) { |
.Times(1); |
EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2)) |
.Times(1); |
- payload_router_->SetTargetSendBitrates(bitrates); |
+ payload_router.SetTargetSendBitrates(bitrates); |
bitrates.resize(1); |
EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1)) |
.Times(1); |
EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2)) |
.Times(0); |
- payload_router_->SetTargetSendBitrates(bitrates); |
+ payload_router.SetTargetSendBitrates(bitrates); |
} |
} // namespace webrtc |