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

Side by Side Diff: modules/module_common_types_unittest.cc

Issue 3014683002: Revert of Remove various IDs (Closed)
Patch Set: 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;
31 constexpr uint32_t kTimestamp = 27; 32 constexpr uint32_t kTimestamp = 27;
32 constexpr int kSampleRateHz = 16000; 33 constexpr int kSampleRateHz = 16000;
33 constexpr size_t kNumChannels = 1; 34 constexpr size_t kNumChannels = 1;
34 constexpr size_t kSamplesPerChannel = kSampleRateHz / 100; 35 constexpr size_t kSamplesPerChannel = kSampleRateHz / 100;
35 36
36 } // namespace 37 } // namespace
37 38
38 TEST(AudioFrameTest, FrameStartsMuted) { 39 TEST(AudioFrameTest, FrameStartsMuted) {
39 AudioFrame frame; 40 AudioFrame frame;
40 EXPECT_TRUE(frame.muted()); 41 EXPECT_TRUE(frame.muted());
(...skipping 15 matching lines...) Expand all
56 } 57 }
57 ASSERT_TRUE(AllSamplesAre(17, frame)); 58 ASSERT_TRUE(AllSamplesAre(17, frame));
58 frame.Mute(); 59 frame.Mute();
59 EXPECT_TRUE(frame.muted()); 60 EXPECT_TRUE(frame.muted());
60 EXPECT_TRUE(AllSamplesAre(0, frame)); 61 EXPECT_TRUE(AllSamplesAre(0, frame));
61 } 62 }
62 63
63 TEST(AudioFrameTest, UpdateFrame) { 64 TEST(AudioFrameTest, UpdateFrame) {
64 AudioFrame frame; 65 AudioFrame frame;
65 int16_t samples[kNumChannels * kSamplesPerChannel] = {17}; 66 int16_t samples[kNumChannels * kSamplesPerChannel] = {17};
66 frame.UpdateFrame(kTimestamp, samples, kSamplesPerChannel, kSampleRateHz, 67 frame.UpdateFrame(kId, kTimestamp, samples, kSamplesPerChannel, kSampleRateHz,
67 AudioFrame::kPLC, AudioFrame::kVadActive, kNumChannels); 68 AudioFrame::kPLC, AudioFrame::kVadActive, kNumChannels);
68 69
70 EXPECT_EQ(kId, frame.id_);
69 EXPECT_EQ(kTimestamp, frame.timestamp_); 71 EXPECT_EQ(kTimestamp, frame.timestamp_);
70 EXPECT_EQ(kSamplesPerChannel, frame.samples_per_channel_); 72 EXPECT_EQ(kSamplesPerChannel, frame.samples_per_channel_);
71 EXPECT_EQ(kSampleRateHz, frame.sample_rate_hz_); 73 EXPECT_EQ(kSampleRateHz, frame.sample_rate_hz_);
72 EXPECT_EQ(AudioFrame::kPLC, frame.speech_type_); 74 EXPECT_EQ(AudioFrame::kPLC, frame.speech_type_);
73 EXPECT_EQ(AudioFrame::kVadActive, frame.vad_activity_); 75 EXPECT_EQ(AudioFrame::kVadActive, frame.vad_activity_);
74 EXPECT_EQ(kNumChannels, frame.num_channels_); 76 EXPECT_EQ(kNumChannels, frame.num_channels_);
75 77
76 EXPECT_FALSE(frame.muted()); 78 EXPECT_FALSE(frame.muted());
77 EXPECT_EQ(0, memcmp(samples, frame.data(), sizeof(samples))); 79 EXPECT_EQ(0, memcmp(samples, frame.data(), sizeof(samples)));
78 80
79 frame.UpdateFrame(kTimestamp, nullptr /* data*/, kSamplesPerChannel, 81 frame.UpdateFrame(kId, kTimestamp, nullptr /* data*/, kSamplesPerChannel,
80 kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive, 82 kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
81 kNumChannels); 83 kNumChannels);
82 EXPECT_TRUE(frame.muted()); 84 EXPECT_TRUE(frame.muted());
83 EXPECT_TRUE(AllSamplesAre(0, frame)); 85 EXPECT_TRUE(AllSamplesAre(0, frame));
84 } 86 }
85 87
86 TEST(AudioFrameTest, CopyFrom) { 88 TEST(AudioFrameTest, CopyFrom) {
87 AudioFrame frame1; 89 AudioFrame frame1;
88 AudioFrame frame2; 90 AudioFrame frame2;
89 91
90 int16_t samples[kNumChannels * kSamplesPerChannel] = {17}; 92 int16_t samples[kNumChannels * kSamplesPerChannel] = {17};
91 frame2.UpdateFrame(kTimestamp, samples, kSamplesPerChannel, 93 frame2.UpdateFrame(kId, kTimestamp, samples, kSamplesPerChannel,
92 kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive, 94 kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
93 kNumChannels); 95 kNumChannels);
94 frame1.CopyFrom(frame2); 96 frame1.CopyFrom(frame2);
95 97
98 EXPECT_EQ(frame2.id_, frame1.id_);
96 EXPECT_EQ(frame2.timestamp_, frame1.timestamp_); 99 EXPECT_EQ(frame2.timestamp_, frame1.timestamp_);
97 EXPECT_EQ(frame2.samples_per_channel_, frame1.samples_per_channel_); 100 EXPECT_EQ(frame2.samples_per_channel_, frame1.samples_per_channel_);
98 EXPECT_EQ(frame2.sample_rate_hz_, frame1.sample_rate_hz_); 101 EXPECT_EQ(frame2.sample_rate_hz_, frame1.sample_rate_hz_);
99 EXPECT_EQ(frame2.speech_type_, frame1.speech_type_); 102 EXPECT_EQ(frame2.speech_type_, frame1.speech_type_);
100 EXPECT_EQ(frame2.vad_activity_, frame1.vad_activity_); 103 EXPECT_EQ(frame2.vad_activity_, frame1.vad_activity_);
101 EXPECT_EQ(frame2.num_channels_, frame1.num_channels_); 104 EXPECT_EQ(frame2.num_channels_, frame1.num_channels_);
102 105
103 EXPECT_EQ(frame2.muted(), frame1.muted()); 106 EXPECT_EQ(frame2.muted(), frame1.muted());
104 EXPECT_EQ(0, memcmp(frame2.data(), frame1.data(), sizeof(samples))); 107 EXPECT_EQ(0, memcmp(frame2.data(), frame1.data(), sizeof(samples)));
105 108
106 frame2.UpdateFrame(kTimestamp, nullptr /* data */, kSamplesPerChannel, 109 frame2.UpdateFrame(kId, kTimestamp, nullptr /* data */, kSamplesPerChannel,
107 kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive, 110 kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
108 kNumChannels); 111 kNumChannels);
109 frame1.CopyFrom(frame2); 112 frame1.CopyFrom(frame2);
110 113
111 EXPECT_EQ(frame2.muted(), frame1.muted()); 114 EXPECT_EQ(frame2.muted(), frame1.muted());
112 EXPECT_EQ(0, memcmp(frame2.data(), frame1.data(), sizeof(samples))); 115 EXPECT_EQ(0, memcmp(frame2.data(), frame1.data(), sizeof(samples)));
113 } 116 }
114 117
115 TEST(IsNewerSequenceNumber, Equal) { 118 TEST(IsNewerSequenceNumber, Equal) {
116 EXPECT_FALSE(IsNewerSequenceNumber(0x0001, 0x0001)); 119 EXPECT_FALSE(IsNewerSequenceNumber(0x0001, 0x0001));
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 unwrapper.UpdateLast(ts); 316 unwrapper.UpdateLast(ts);
314 for (int i = 0; i <= kNumWraps * 2; ++i) { 317 for (int i = 0; i <= kNumWraps * 2; ++i) {
315 int64_t unwrapped = 318 int64_t unwrapped =
316 unwrapper.Unwrap(static_cast<uint32_t>(ts & 0xFFFFFFFF)); 319 unwrapper.Unwrap(static_cast<uint32_t>(ts & 0xFFFFFFFF));
317 EXPECT_EQ(ts, unwrapped); 320 EXPECT_EQ(ts, unwrapped);
318 ts -= kMaxDecrease; 321 ts -= kMaxDecrease;
319 } 322 }
320 } 323 }
321 324
322 } // namespace webrtc 325 } // 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