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

Side by Side Diff: media/base/audio_bus_unittest.cc

Issue 2845813004: Add unit test for AudioBus::CreateWrapper() (Closed)
Patch Set: Add unit test for AudioBus::CreateWrapper() Created 3 years, 7 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 | « media/base/audio_bus.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <limits> 8 #include <limits>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 // Verify Create(...) using AudioParameters works as advertised. 126 // Verify Create(...) using AudioParameters works as advertised.
127 TEST_F(AudioBusTest, CreateUsingAudioParameters) { 127 TEST_F(AudioBusTest, CreateUsingAudioParameters) {
128 std::unique_ptr<AudioBus> bus = AudioBus::Create( 128 std::unique_ptr<AudioBus> bus = AudioBus::Create(
129 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, 129 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout,
130 kSampleRate, 32, kFrameCount)); 130 kSampleRate, 32, kFrameCount));
131 VerifyChannelAndFrameCount(bus.get()); 131 VerifyChannelAndFrameCount(bus.get());
132 VerifyReadWriteAndAlignment(bus.get()); 132 VerifyReadWriteAndAlignment(bus.get());
133 } 133 }
134 134
135 // Verify an AudioBus created via CreateWrapper(...) works as advertised.
136 TEST_F(AudioBusTest, CreateWrapper) {
137 data_.reserve(kChannels);
138 for (int i = 0; i < kChannels; ++i) {
139 data_.push_back(static_cast<float*>(base::AlignedAlloc(
140 sizeof(*data_[i]) * kFrameCount, AudioBus::kChannelAlignment)));
141 }
142
143 std::unique_ptr<AudioBus> bus = AudioBus::CreateWrapper(kChannels);
144 bus->set_frames(kFrameCount);
145 for (int i = 0; i < bus->channels(); ++i)
146 bus->SetChannelData(i, data_[i]);
147
148 VerifyChannelAndFrameCount(bus.get());
149 VerifyReadWriteAndAlignment(bus.get());
150 }
151
135 // Verify an AudioBus created via wrapping a vector works as advertised. 152 // Verify an AudioBus created via wrapping a vector works as advertised.
136 TEST_F(AudioBusTest, WrapVector) { 153 TEST_F(AudioBusTest, WrapVector) {
137 data_.reserve(kChannels); 154 data_.reserve(kChannels);
138 for (int i = 0; i < kChannels; ++i) { 155 for (int i = 0; i < kChannels; ++i) {
139 data_.push_back(static_cast<float*>(base::AlignedAlloc( 156 data_.push_back(static_cast<float*>(base::AlignedAlloc(
140 sizeof(*data_[i]) * kFrameCount, AudioBus::kChannelAlignment))); 157 sizeof(*data_[i]) * kFrameCount, AudioBus::kChannelAlignment)));
141 } 158 }
142 159
143 std::unique_ptr<AudioBus> bus = AudioBus::WrapVector(kFrameCount, data_); 160 std::unique_ptr<AudioBus> bus = AudioBus::WrapVector(kFrameCount, data_);
144 VerifyChannelAndFrameCount(bus.get()); 161 VerifyChannelAndFrameCount(bus.get());
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 676
660 // Verify zero volume case. 677 // Verify zero volume case.
661 bus->Scale(0); 678 bus->Scale(0);
662 for (int i = 0; i < bus->channels(); ++i) { 679 for (int i = 0; i < bus->channels(); ++i) {
663 SCOPED_TRACE("Zero Scale"); 680 SCOPED_TRACE("Zero Scale");
664 VerifyArrayIsFilledWithValue(bus->channel(i), bus->frames(), 0); 681 VerifyArrayIsFilledWithValue(bus->channel(i), bus->frames(), 0);
665 } 682 }
666 } 683 }
667 684
668 } // namespace media 685 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_bus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698