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 // Unit tests for FilePlayer. | 11 // Unit tests for FilePlayer. |
12 | 12 |
13 #include "webrtc/modules/utility/include/file_player.h" | 13 #include "webrtc/modules/utility/include/file_player.h" |
14 | 14 |
15 #include <stdio.h> | 15 #include <stdio.h> |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "gflags/gflags.h" | 18 #include "gflags/gflags.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "webrtc/base/md5digest.h" | 20 #include "webrtc/base/md5digest.h" |
21 #include "webrtc/base/stringencode.h" | 21 #include "webrtc/base/stringencode.h" |
22 #include "webrtc/test/testsupport/fileutils.h" | 22 #include "webrtc/test/testsupport/fileutils.h" |
23 #include "webrtc/test/testsupport/gtest_disable.h" | |
24 | 23 |
25 DEFINE_bool(file_player_output, false, "Generate reference files."); | 24 DEFINE_bool(file_player_output, false, "Generate reference files."); |
26 | 25 |
27 namespace webrtc { | 26 namespace webrtc { |
28 | 27 |
29 class FilePlayerTest : public ::testing::Test { | 28 class FilePlayerTest : public ::testing::Test { |
30 protected: | 29 protected: |
31 static const uint32_t kId = 0; | 30 static const uint32_t kId = 0; |
32 static const FileFormats kFileFormat = kFileFormatWavFile; | 31 static const FileFormats kFileFormat = kFileFormatWavFile; |
33 static const int kSampleRateHz = 8000; | 32 static const int kSampleRateHz = 8000; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 EXPECT_EQ(rtc::Md5Digest::kSize, | 74 EXPECT_EQ(rtc::Md5Digest::kSize, |
76 checksum.Finish(checksum_result, rtc::Md5Digest::kSize)); | 75 checksum.Finish(checksum_result, rtc::Md5Digest::kSize)); |
77 EXPECT_EQ(ref_checksum, | 76 EXPECT_EQ(ref_checksum, |
78 rtc::hex_encode(checksum_result, sizeof(checksum_result))); | 77 rtc::hex_encode(checksum_result, sizeof(checksum_result))); |
79 } | 78 } |
80 | 79 |
81 FilePlayer* player_; | 80 FilePlayer* player_; |
82 FILE* output_file_; | 81 FILE* output_file_; |
83 }; | 82 }; |
84 | 83 |
85 TEST_F(FilePlayerTest, DISABLED_ON_IOS(PlayWavPcmuFile)) { | 84 #if defined(WEBRTC_IOS) |
| 85 #define MAYBE_PlayWavPcmuFile DISABLED_PlayWavPcmuFile |
| 86 #else |
| 87 #define MAYBE_PlayWavPcmuFile PlayWavPcmuFile |
| 88 #endif |
| 89 TEST_F(FilePlayerTest, MAYBE_PlayWavPcmuFile) { |
86 const std::string kFileName = | 90 const std::string kFileName = |
87 test::ResourcePath("utility/encapsulated_pcmu_8khz", "wav"); | 91 test::ResourcePath("utility/encapsulated_pcmu_8khz", "wav"); |
88 // The file is longer than this, but keeping the output shorter limits the | 92 // The file is longer than this, but keeping the output shorter limits the |
89 // runtime for the test. | 93 // runtime for the test. |
90 const int kOutputLengthMs = 10000; | 94 const int kOutputLengthMs = 10000; |
91 const std::string kRefChecksum = "c74e7fd432d439b1311e1c16815b3e9a"; | 95 const std::string kRefChecksum = "c74e7fd432d439b1311e1c16815b3e9a"; |
92 | 96 |
93 PlayFileAndCheck(kFileName, kRefChecksum, kOutputLengthMs); | 97 PlayFileAndCheck(kFileName, kRefChecksum, kOutputLengthMs); |
94 } | 98 } |
95 | 99 |
96 TEST_F(FilePlayerTest, DISABLED_ON_IOS(PlayWavPcm16File)) { | 100 #if defined(WEBRTC_IOS) |
| 101 #define MAYBE_PlayWavPcm16File DISABLED_PlayWavPcm16File |
| 102 #else |
| 103 #define MAYBE_PlayWavPcm16File PlayWavPcm16File |
| 104 #endif |
| 105 TEST_F(FilePlayerTest, MAYBE_PlayWavPcm16File) { |
97 const std::string kFileName = | 106 const std::string kFileName = |
98 test::ResourcePath("utility/encapsulated_pcm16b_8khz", "wav"); | 107 test::ResourcePath("utility/encapsulated_pcm16b_8khz", "wav"); |
99 // The file is longer than this, but keeping the output shorter limits the | 108 // The file is longer than this, but keeping the output shorter limits the |
100 // runtime for the test. | 109 // runtime for the test. |
101 const int kOutputLengthMs = 10000; | 110 const int kOutputLengthMs = 10000; |
102 const std::string kRefChecksum = "e41d7e1dac8aeae9f21e8e03cd7ecd71"; | 111 const std::string kRefChecksum = "e41d7e1dac8aeae9f21e8e03cd7ecd71"; |
103 | 112 |
104 PlayFileAndCheck(kFileName, kRefChecksum, kOutputLengthMs); | 113 PlayFileAndCheck(kFileName, kRefChecksum, kOutputLengthMs); |
105 } | 114 } |
106 | 115 |
107 } // namespace webrtc | 116 } // namespace webrtc |
OLD | NEW |