OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h" | 13 #include "webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h" |
14 #include "webrtc/test/testsupport/fileutils.h" | 14 #include "webrtc/test/testsupport/fileutils.h" |
15 #include "webrtc/test/testsupport/gtest_disable.h" | |
16 | 15 |
17 struct WebRtcISACStruct; | 16 struct WebRtcISACStruct; |
18 | 17 |
19 namespace webrtc { | 18 namespace webrtc { |
20 | 19 |
21 // Number of samples in a 60 ms, sampled at 32 kHz. | 20 // Number of samples in a 60 ms, sampled at 32 kHz. |
22 const int kIsacNumberOfSamples = 320 * 6; | 21 const int kIsacNumberOfSamples = 320 * 6; |
23 // Maximum number of bytes in output bitstream. | 22 // Maximum number of bytes in output bitstream. |
24 const size_t kMaxBytes = 1000; | 23 const size_t kMaxBytes = 1000; |
25 | 24 |
(...skipping 22 matching lines...) Expand all Loading... |
48 input_file = fopen(file_name.c_str(), "rb"); | 47 input_file = fopen(file_name.c_str(), "rb"); |
49 ASSERT_TRUE(input_file != NULL); | 48 ASSERT_TRUE(input_file != NULL); |
50 ASSERT_EQ(kIsacNumberOfSamples, | 49 ASSERT_EQ(kIsacNumberOfSamples, |
51 static_cast<int32_t>(fread(speech_data_, sizeof(int16_t), | 50 static_cast<int32_t>(fread(speech_data_, sizeof(int16_t), |
52 kIsacNumberOfSamples, input_file))); | 51 kIsacNumberOfSamples, input_file))); |
53 fclose(input_file); | 52 fclose(input_file); |
54 input_file = NULL; | 53 input_file = NULL; |
55 } | 54 } |
56 | 55 |
57 // Test failing Create. | 56 // Test failing Create. |
58 TEST_F(IsacTest, DISABLED_ON_IOS(IsacCreateFail)) { | 57 TEST_F(IsacTest, IsacCreateFail) { |
59 // Test to see that an invalid pointer is caught. | 58 // Test to see that an invalid pointer is caught. |
60 EXPECT_EQ(-1, WebRtcIsac_Create(NULL)); | 59 EXPECT_EQ(-1, WebRtcIsac_Create(NULL)); |
61 } | 60 } |
62 | 61 |
63 // Test failing Free. | 62 // Test failing Free. |
64 TEST_F(IsacTest, DISABLED_ON_IOS(IsacFreeFail)) { | 63 TEST_F(IsacTest, IsacFreeFail) { |
65 // Test to see that free function doesn't crash. | 64 // Test to see that free function doesn't crash. |
66 EXPECT_EQ(0, WebRtcIsac_Free(NULL)); | 65 EXPECT_EQ(0, WebRtcIsac_Free(NULL)); |
67 } | 66 } |
68 | 67 |
69 // Test normal Create and Free. | 68 // Test normal Create and Free. |
70 TEST_F(IsacTest, DISABLED_ON_IOS(IsacCreateFree)) { | 69 TEST_F(IsacTest, IsacCreateFree) { |
71 EXPECT_EQ(0, WebRtcIsac_Create(&isac_codec_)); | 70 EXPECT_EQ(0, WebRtcIsac_Create(&isac_codec_)); |
72 EXPECT_TRUE(isac_codec_ != NULL); | 71 EXPECT_TRUE(isac_codec_ != NULL); |
73 EXPECT_EQ(0, WebRtcIsac_Free(isac_codec_));} | 72 EXPECT_EQ(0, WebRtcIsac_Free(isac_codec_));} |
74 | 73 |
75 TEST_F(IsacTest, DISABLED_ON_IOS(IsacUpdateBWE)) { | 74 TEST_F(IsacTest, IsacUpdateBWE) { |
76 // Create encoder memory. | 75 // Create encoder memory. |
77 EXPECT_EQ(0, WebRtcIsac_Create(&isac_codec_)); | 76 EXPECT_EQ(0, WebRtcIsac_Create(&isac_codec_)); |
78 | 77 |
79 // Init encoder (adaptive mode) and decoder. | 78 // Init encoder (adaptive mode) and decoder. |
80 WebRtcIsac_EncoderInit(isac_codec_, 0); | 79 WebRtcIsac_EncoderInit(isac_codec_, 0); |
81 WebRtcIsac_DecoderInit(isac_codec_); | 80 WebRtcIsac_DecoderInit(isac_codec_); |
82 | 81 |
83 int encoded_bytes; | 82 int encoded_bytes; |
84 | 83 |
85 // Test with call with a small packet (sync packet). | 84 // Test with call with a small packet (sync packet). |
(...skipping 15 matching lines...) Expand all Loading... |
101 | 100 |
102 // Call to update bandwidth estimator with real data. | 101 // Call to update bandwidth estimator with real data. |
103 EXPECT_EQ(0, WebRtcIsac_UpdateBwEstimate(isac_codec_, bitstream_, | 102 EXPECT_EQ(0, WebRtcIsac_UpdateBwEstimate(isac_codec_, bitstream_, |
104 encoded_bytes, 1, 12345, 56789)); | 103 encoded_bytes, 1, 12345, 56789)); |
105 | 104 |
106 // Free memory. | 105 // Free memory. |
107 EXPECT_EQ(0, WebRtcIsac_Free(isac_codec_)); | 106 EXPECT_EQ(0, WebRtcIsac_Free(isac_codec_)); |
108 } | 107 } |
109 | 108 |
110 } // namespace webrtc | 109 } // namespace webrtc |
OLD | NEW |