OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/copresence/mediums/audio/audio_player.h" | 5 #include "components/copresence/mediums/audio/audio_player.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "components/copresence/mediums/audio/audio_player_impl.h" | 9 #include "components/copresence/mediums/audio/audio_player_impl.h" |
10 #include "components/copresence/public/copresence_constants.h" | 10 #include "components/copresence/public/copresence_constants.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 namespace copresence { | 71 namespace copresence { |
72 | 72 |
73 class AudioPlayerTest : public testing::Test, | 73 class AudioPlayerTest : public testing::Test, |
74 public base::SupportsWeakPtr<AudioPlayerTest> { | 74 public base::SupportsWeakPtr<AudioPlayerTest> { |
75 public: | 75 public: |
76 AudioPlayerTest() : buffer_index_(0), player_(NULL) { | 76 AudioPlayerTest() : buffer_index_(0), player_(NULL) { |
77 if (!media::AudioManager::Get()) | 77 if (!media::AudioManager::Get()) |
78 media::AudioManager::CreateForTesting(); | 78 media::AudioManager::CreateForTesting(); |
79 } | 79 } |
80 | 80 |
81 virtual ~AudioPlayerTest() { DeletePlayer(); } | 81 ~AudioPlayerTest() override { DeletePlayer(); } |
82 | 82 |
83 void CreatePlayer() { | 83 void CreatePlayer() { |
84 DeletePlayer(); | 84 DeletePlayer(); |
85 player_ = new AudioPlayerImpl(); | 85 player_ = new AudioPlayerImpl(); |
86 player_->set_output_stream_for_testing(new TestAudioOutputStream( | 86 player_->set_output_stream_for_testing(new TestAudioOutputStream( |
87 kDefaultFrameCount, | 87 kDefaultFrameCount, |
88 kMaxFrameCount, | 88 kMaxFrameCount, |
89 base::Bind(&AudioPlayerTest::GatherSamples, AsWeakPtr()))); | 89 base::Bind(&AudioPlayerTest::GatherSamples, AsWeakPtr()))); |
90 player_->Initialize(); | 90 player_->Initialize(); |
91 } | 91 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 TEST_F(AudioPlayerTest, PlayingEndToEnd) { | 182 TEST_F(AudioPlayerTest, PlayingEndToEnd) { |
183 const int kNumSamples = kDefaultFrameCount * 10; | 183 const int kNumSamples = kDefaultFrameCount * 10; |
184 CreatePlayer(); | 184 CreatePlayer(); |
185 | 185 |
186 PlayAndVerifySamples(CreateRandomAudioRefCounted(0x1337, 1, kNumSamples)); | 186 PlayAndVerifySamples(CreateRandomAudioRefCounted(0x1337, 1, kNumSamples)); |
187 | 187 |
188 DeletePlayer(); | 188 DeletePlayer(); |
189 } | 189 } |
190 | 190 |
191 } // namespace copresence | 191 } // namespace copresence |
OLD | NEW |