Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: modules/module_common_types_unittest.cc

Issue 3019543002: Remove various IDs (Closed)
Patch Set: rebase+build error Created 3 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « modules/include/module_common_types.h ('k') | voice_engine/channel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10
(...skipping 10 matching lines...) Expand all
21 bool AllSamplesAre(int16_t sample, const AudioFrame& frame) { 21 bool AllSamplesAre(int16_t sample, const AudioFrame& frame) {
22 const int16_t* frame_data = frame.data(); 22 const int16_t* frame_data = frame.data();
23 for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; i++) { 23 for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; i++) {
24 if (frame_data[i] != sample) { 24 if (frame_data[i] != sample) {
25 return false; 25 return false;
26 } 26 }
27 } 27 }
28 return true; 28 return true;
29 } 29 }
30 30
31 constexpr int kId = 16;
32 constexpr uint32_t kTimestamp = 27; 31 constexpr uint32_t kTimestamp = 27;
33 constexpr int kSampleRateHz = 16000; 32 constexpr int kSampleRateHz = 16000;
34 constexpr size_t kNumChannels = 1; 33 constexpr size_t kNumChannels = 1;
35 constexpr size_t kSamplesPerChannel = kSampleRateHz / 100; 34 constexpr size_t kSamplesPerChannel = kSampleRateHz / 100;
36 35
37 } // namespace 36 } // namespace
38 37
39 TEST(AudioFrameTest, FrameStartsMuted) { 38 TEST(AudioFrameTest, FrameStartsMuted) {
40 AudioFrame frame; 39 AudioFrame frame;
41 EXPECT_TRUE(frame.muted()); 40 EXPECT_TRUE(frame.muted());
(...skipping 15 matching lines...) Expand all
57 } 56 }
58 ASSERT_TRUE(AllSamplesAre(17, frame)); 57 ASSERT_TRUE(AllSamplesAre(17, frame));
59 frame.Mute(); 58 frame.Mute();
60 EXPECT_TRUE(frame.muted()); 59 EXPECT_TRUE(frame.muted());
61 EXPECT_TRUE(AllSamplesAre(0, frame)); 60 EXPECT_TRUE(AllSamplesAre(0, frame));
62 } 61 }
63 62
64 TEST(AudioFrameTest, UpdateFrame) { 63 TEST(AudioFrameTest, UpdateFrame) {
65 AudioFrame frame; 64 AudioFrame frame;
66 int16_t samples[kNumChannels * kSamplesPerChannel] = {17}; 65 int16_t samples[kNumChannels * kSamplesPerChannel] = {17};
67 frame.UpdateFrame(kId, kTimestamp, samples, kSamplesPerChannel, kSampleRateHz, 66 frame.UpdateFrame(kTimestamp, samples, kSamplesPerChannel, kSampleRateHz,
68 AudioFrame::kPLC, AudioFrame::kVadActive, kNumChannels); 67 AudioFrame::kPLC, AudioFrame::kVadActive, kNumChannels);
69 68
70 EXPECT_EQ(kId, frame.id_);
71 EXPECT_EQ(kTimestamp, frame.timestamp_); 69 EXPECT_EQ(kTimestamp, frame.timestamp_);
72 EXPECT_EQ(kSamplesPerChannel, frame.samples_per_channel_); 70 EXPECT_EQ(kSamplesPerChannel, frame.samples_per_channel_);
73 EXPECT_EQ(kSampleRateHz, frame.sample_rate_hz_); 71 EXPECT_EQ(kSampleRateHz, frame.sample_rate_hz_);
74 EXPECT_EQ(AudioFrame::kPLC, frame.speech_type_); 72 EXPECT_EQ(AudioFrame::kPLC, frame.speech_type_);
75 EXPECT_EQ(AudioFrame::kVadActive, frame.vad_activity_); 73 EXPECT_EQ(AudioFrame::kVadActive, frame.vad_activity_);
76 EXPECT_EQ(kNumChannels, frame.num_channels_); 74 EXPECT_EQ(kNumChannels, frame.num_channels_);
77 75
78 EXPECT_FALSE(frame.muted()); 76 EXPECT_FALSE(frame.muted());
79 EXPECT_EQ(0, memcmp(samples, frame.data(), sizeof(samples))); 77 EXPECT_EQ(0, memcmp(samples, frame.data(), sizeof(samples)));
80 78
81 frame.UpdateFrame(kId, kTimestamp, nullptr /* data*/, kSamplesPerChannel, 79 frame.UpdateFrame(kTimestamp, nullptr /* data*/, kSamplesPerChannel,
82 kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive, 80 kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
83 kNumChannels); 81 kNumChannels);
84 EXPECT_TRUE(frame.muted()); 82 EXPECT_TRUE(frame.muted());
85 EXPECT_TRUE(AllSamplesAre(0, frame)); 83 EXPECT_TRUE(AllSamplesAre(0, frame));
86 } 84 }
87 85
88 TEST(AudioFrameTest, CopyFrom) { 86 TEST(AudioFrameTest, CopyFrom) {
89 AudioFrame frame1; 87 AudioFrame frame1;
90 AudioFrame frame2; 88 AudioFrame frame2;
91 89
92 int16_t samples[kNumChannels * kSamplesPerChannel] = {17}; 90 int16_t samples[kNumChannels * kSamplesPerChannel] = {17};
93 frame2.UpdateFrame(kId, kTimestamp, samples, kSamplesPerChannel, 91 frame2.UpdateFrame(kTimestamp, samples, kSamplesPerChannel,
94 kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive, 92 kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
95 kNumChannels); 93 kNumChannels);
96 frame1.CopyFrom(frame2); 94 frame1.CopyFrom(frame2);
97 95
98 EXPECT_EQ(frame2.id_, frame1.id_);
99 EXPECT_EQ(frame2.timestamp_, frame1.timestamp_); 96 EXPECT_EQ(frame2.timestamp_, frame1.timestamp_);
100 EXPECT_EQ(frame2.samples_per_channel_, frame1.samples_per_channel_); 97 EXPECT_EQ(frame2.samples_per_channel_, frame1.samples_per_channel_);
101 EXPECT_EQ(frame2.sample_rate_hz_, frame1.sample_rate_hz_); 98 EXPECT_EQ(frame2.sample_rate_hz_, frame1.sample_rate_hz_);
102 EXPECT_EQ(frame2.speech_type_, frame1.speech_type_); 99 EXPECT_EQ(frame2.speech_type_, frame1.speech_type_);
103 EXPECT_EQ(frame2.vad_activity_, frame1.vad_activity_); 100 EXPECT_EQ(frame2.vad_activity_, frame1.vad_activity_);
104 EXPECT_EQ(frame2.num_channels_, frame1.num_channels_); 101 EXPECT_EQ(frame2.num_channels_, frame1.num_channels_);
105 102
106 EXPECT_EQ(frame2.muted(), frame1.muted()); 103 EXPECT_EQ(frame2.muted(), frame1.muted());
107 EXPECT_EQ(0, memcmp(frame2.data(), frame1.data(), sizeof(samples))); 104 EXPECT_EQ(0, memcmp(frame2.data(), frame1.data(), sizeof(samples)));
108 105
109 frame2.UpdateFrame(kId, kTimestamp, nullptr /* data */, kSamplesPerChannel, 106 frame2.UpdateFrame(kTimestamp, nullptr /* data */, kSamplesPerChannel,
110 kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive, 107 kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
111 kNumChannels); 108 kNumChannels);
112 frame1.CopyFrom(frame2); 109 frame1.CopyFrom(frame2);
113 110
114 EXPECT_EQ(frame2.muted(), frame1.muted()); 111 EXPECT_EQ(frame2.muted(), frame1.muted());
115 EXPECT_EQ(0, memcmp(frame2.data(), frame1.data(), sizeof(samples))); 112 EXPECT_EQ(0, memcmp(frame2.data(), frame1.data(), sizeof(samples)));
116 } 113 }
117 114
118 TEST(IsNewerSequenceNumber, Equal) { 115 TEST(IsNewerSequenceNumber, Equal) {
119 EXPECT_FALSE(IsNewerSequenceNumber(0x0001, 0x0001)); 116 EXPECT_FALSE(IsNewerSequenceNumber(0x0001, 0x0001));
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 unwrapper.UpdateLast(ts); 313 unwrapper.UpdateLast(ts);
317 for (int i = 0; i <= kNumWraps * 2; ++i) { 314 for (int i = 0; i <= kNumWraps * 2; ++i) {
318 int64_t unwrapped = 315 int64_t unwrapped =
319 unwrapper.Unwrap(static_cast<uint32_t>(ts & 0xFFFFFFFF)); 316 unwrapper.Unwrap(static_cast<uint32_t>(ts & 0xFFFFFFFF));
320 EXPECT_EQ(ts, unwrapped); 317 EXPECT_EQ(ts, unwrapped);
321 ts -= kMaxDecrease; 318 ts -= kMaxDecrease;
322 } 319 }
323 } 320 }
324 321
325 } // namespace webrtc 322 } // namespace webrtc
OLDNEW
« no previous file with comments | « modules/include/module_common_types.h ('k') | voice_engine/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698