noahric | be850e1 | 2017-01-20 01:07:26 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "webrtc/media/engine/webrtcvideoencoderfactory.h" |
| 12 | |
| 13 | #include "webrtc/test/gtest.h" |
| 14 | |
| 15 | class WebRtcVideoEncoderFactoryForTest |
| 16 | : public cricket::WebRtcVideoEncoderFactory { |
| 17 | public: |
| 18 | WebRtcVideoEncoderFactoryForTest() { |
magjed | c1a8974 | 2017-05-12 00:24:40 -0700 | [diff] [blame^] | 19 | codecs_.push_back(cricket::VideoCodec("H264")); |
| 20 | codecs_.push_back(cricket::VideoCodec("VP8")); |
noahric | be850e1 | 2017-01-20 01:07:26 -0800 | [diff] [blame] | 21 | } |
| 22 | |
magjed | c1a8974 | 2017-05-12 00:24:40 -0700 | [diff] [blame^] | 23 | webrtc::VideoEncoder* CreateVideoEncoder( |
| 24 | const cricket::VideoCodec& codec) override { |
| 25 | return nullptr; |
| 26 | } |
| 27 | |
| 28 | const std::vector<cricket::VideoCodec>& supported_codecs() const override { |
| 29 | return codecs_; |
| 30 | } |
noahric | be850e1 | 2017-01-20 01:07:26 -0800 | [diff] [blame] | 31 | |
| 32 | void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) override {} |
| 33 | |
magjed | c1a8974 | 2017-05-12 00:24:40 -0700 | [diff] [blame^] | 34 | std::vector<cricket::VideoCodec> codecs_; |
noahric | be850e1 | 2017-01-20 01:07:26 -0800 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | TEST(WebRtcVideoEncoderFactoryTest, TestMultipleCallsToSupportedCodecs) { |
| 38 | WebRtcVideoEncoderFactoryForTest factory; |
| 39 | EXPECT_EQ(2u, factory.supported_codecs().size()); |
| 40 | EXPECT_EQ("H264", factory.supported_codecs()[0].name); |
| 41 | EXPECT_EQ("VP8", factory.supported_codecs()[1].name); |
| 42 | |
| 43 | // The codec list doesn't grow when called repeatedly. |
| 44 | EXPECT_EQ(2u, factory.supported_codecs().size()); |
| 45 | } |