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

Unified Diff: media/base/audio_bus_unittest.cc

Issue 2845813004: Add unit test for AudioBus::CreateWrapper() (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/audio_bus.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_bus_unittest.cc
diff --git a/media/base/audio_bus_unittest.cc b/media/base/audio_bus_unittest.cc
index 63dcb0cad0aaa85e0b47dc41c92df289a04d3828..4a007f9b093485b707d532ef162ce6336c3a32aa 100644
--- a/media/base/audio_bus_unittest.cc
+++ b/media/base/audio_bus_unittest.cc
@@ -132,6 +132,13 @@ TEST_F(AudioBusTest, CreateUsingAudioParameters) {
VerifyReadWriteAndAlignment(bus.get());
}
+// Verify CreateWrapper(...) method works as advertised.
+TEST_F(AudioBusTest, CreateWrapper) {
+ std::unique_ptr<AudioBus> bus = AudioBus::CreateWrapper(kChannels);
+ EXPECT_EQ(kChannels, bus->channels());
+ EXPECT_EQ(0, bus->frames());
+}
+
// Verify an AudioBus created via wrapping a vector works as advertised.
TEST_F(AudioBusTest, WrapVector) {
data_.reserve(kChannels);
@@ -172,6 +179,28 @@ TEST_F(AudioBusTest, WrapMemory) {
data.get() + data_size / sizeof(*data.get()));
}
+// Verify SetChannelData(...) method works as advertised.
+TEST_F(AudioBusTest, SetChannelData) {
+ data_.reserve(kChannels);
+ for (int i = 0; i < kChannels; ++i) {
+ data_.push_back(static_cast<float*>(
+ base::AlignedAlloc(sizeof(*data_[i]), AudioBus::kChannelAlignment)));
+ }
+ std::unique_ptr<AudioBus> bus = AudioBus::CreateWrapper(kChannels);
+ for (int i = 0; i < bus->channels(); ++i)
+ bus->SetChannelData(i, data_[i]);
+
+ for (int i = 0; i < bus->channels(); ++i)
+ EXPECT_EQ(bus->channel(i), data_[i]);
chfremer 2017/04/27 16:55:14 Would it make sense to add VerifyReadWriteAndAli
Chandan 2017/04/27 18:43:07 With number of frames in this test being always ze
chfremer 2017/04/27 20:19:36 Hmm, I feel that for the cases where AudioBus itse
Chandan 2017/04/28 06:07:29 Sure. I will add Alignment verification for this t
chfremer 2017/04/28 16:39:48 Not needed for the tests involving AudioBus::Creat
+}
+
+// Verify set_frames(...) method works as advertised.
+TEST_F(AudioBusTest, SetFrames) {
+ std::unique_ptr<AudioBus> bus = AudioBus::CreateWrapper(kChannels);
+ bus->set_frames(kFrameCount);
+ EXPECT_EQ(kFrameCount, bus->frames());
chfremer 2017/04/27 16:55:14 Would it make sense to add VerifyReadWriteAndAli
Chandan 2017/04/27 18:43:07 With no channel data allocated in this test, verif
chfremer 2017/04/27 20:19:36 True. I guess, when I added the TODO for adding te
Chandan 2017/04/28 06:07:29 By 'everything' you mean read/write/alignment? Im
chfremer 2017/04/28 16:39:48 Sorry about my vague language. Yes I meant read/wr
Chandan 2017/05/02 09:27:06 Right. With the new test in place, these 3 individ
+}
+
// Simulate a shared memory transfer and verify results.
TEST_F(AudioBusTest, CopyTo) {
// Create one bus with AudioParameters and the other through direct values to
« 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