OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <string.h> | 11 #include <string.h> |
12 | 12 |
| 13 #include <memory> |
| 14 |
13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "webrtc/base/scoped_ptr.h" | |
15 #include "webrtc/test/rtp_file_reader.h" | 16 #include "webrtc/test/rtp_file_reader.h" |
16 #include "webrtc/test/rtp_file_writer.h" | 17 #include "webrtc/test/rtp_file_writer.h" |
17 #include "webrtc/test/testsupport/fileutils.h" | 18 #include "webrtc/test/testsupport/fileutils.h" |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 | 21 |
21 class RtpFileWriterTest : public ::testing::Test { | 22 class RtpFileWriterTest : public ::testing::Test { |
22 public: | 23 public: |
23 void Init(const std::string& filename) { | 24 void Init(const std::string& filename) { |
24 filename_ = test::OutputPath() + filename; | 25 filename_ = test::OutputPath() + filename; |
(...skipping 11 matching lines...) Expand all Loading... |
36 memset(packet.data, i, packet.length); | 37 memset(packet.data, i, packet.length); |
37 EXPECT_TRUE(rtp_writer_->WritePacket(&packet)); | 38 EXPECT_TRUE(rtp_writer_->WritePacket(&packet)); |
38 } | 39 } |
39 } | 40 } |
40 | 41 |
41 void CloseOutputFile() { rtp_writer_.reset(); } | 42 void CloseOutputFile() { rtp_writer_.reset(); } |
42 | 43 |
43 void VerifyFileContents(int expected_packets) { | 44 void VerifyFileContents(int expected_packets) { |
44 ASSERT_TRUE(rtp_writer_.get() == NULL) | 45 ASSERT_TRUE(rtp_writer_.get() == NULL) |
45 << "Must call CloseOutputFile before VerifyFileContents"; | 46 << "Must call CloseOutputFile before VerifyFileContents"; |
46 rtc::scoped_ptr<test::RtpFileReader> rtp_reader( | 47 std::unique_ptr<test::RtpFileReader> rtp_reader( |
47 test::RtpFileReader::Create(test::RtpFileReader::kRtpDump, filename_)); | 48 test::RtpFileReader::Create(test::RtpFileReader::kRtpDump, filename_)); |
48 ASSERT_TRUE(rtp_reader.get() != NULL); | 49 ASSERT_TRUE(rtp_reader.get() != NULL); |
49 test::RtpPacket packet; | 50 test::RtpPacket packet; |
50 int i = 0; | 51 int i = 0; |
51 while (rtp_reader->NextPacket(&packet)) { | 52 while (rtp_reader->NextPacket(&packet)) { |
52 ++i; | 53 ++i; |
53 EXPECT_EQ(static_cast<size_t>(i), packet.length); | 54 EXPECT_EQ(static_cast<size_t>(i), packet.length); |
54 EXPECT_EQ(static_cast<size_t>(i), packet.original_length); | 55 EXPECT_EQ(static_cast<size_t>(i), packet.original_length); |
55 EXPECT_EQ(static_cast<uint32_t>(i), packet.time_ms); | 56 EXPECT_EQ(static_cast<uint32_t>(i), packet.time_ms); |
56 for (int j = 0; j < i; ++j) { | 57 for (int j = 0; j < i; ++j) { |
57 EXPECT_EQ(i, packet.data[j]); | 58 EXPECT_EQ(i, packet.data[j]); |
58 } | 59 } |
59 } | 60 } |
60 EXPECT_EQ(expected_packets, i); | 61 EXPECT_EQ(expected_packets, i); |
61 } | 62 } |
62 | 63 |
63 private: | 64 private: |
64 rtc::scoped_ptr<test::RtpFileWriter> rtp_writer_; | 65 std::unique_ptr<test::RtpFileWriter> rtp_writer_; |
65 std::string filename_; | 66 std::string filename_; |
66 }; | 67 }; |
67 | 68 |
68 TEST_F(RtpFileWriterTest, WriteToRtpDump) { | 69 TEST_F(RtpFileWriterTest, WriteToRtpDump) { |
69 Init("test_rtp_file_writer.rtp"); | 70 Init("test_rtp_file_writer.rtp"); |
70 WriteRtpPackets(10); | 71 WriteRtpPackets(10); |
71 CloseOutputFile(); | 72 CloseOutputFile(); |
72 VerifyFileContents(10); | 73 VerifyFileContents(10); |
73 } | 74 } |
74 | 75 |
75 } // namespace webrtc | 76 } // namespace webrtc |
OLD | NEW |