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

Side by Side Diff: media/audio/mac/audio_auhal_mac_unittest.cc

Issue 2023943002: Revert of Forward output glitch information from stream WebRTC log (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/audio/mac/audio_auhal_mac.cc ('k') | media/audio/mac/audio_low_latency_input_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/bind.h"
6 #include "base/macros.h" 5 #include "base/macros.h"
7 #include "base/run_loop.h" 6 #include "base/run_loop.h"
8 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
9 #include "base/test/test_message_loop.h" 8 #include "base/test/test_message_loop.h"
10 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
11 #include "media/audio/audio_io.h" 10 #include "media/audio/audio_io.h"
12 #include "media/audio/audio_manager.h" 11 #include "media/audio/audio_manager.h"
13 #include "media/audio/audio_unittest_util.h" 12 #include "media/audio/audio_unittest_util.h"
14 #include "media/audio/mock_audio_source_callback.h" 13 #include "media/audio/mock_audio_source_callback.h"
15 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
17 16
18 using testing::_; 17 using testing::_;
19 using testing::DoAll; 18 using testing::DoAll;
20 using testing::Return; 19 using testing::Return;
21 20
22 // TODO(crogers): Most of these tests can be made platform agnostic. 21 // TODO(crogers): Most of these tests can be made platform agnostic.
23 // http://crbug.com/223242 22 // http://crbug.com/223242
24 23
25 namespace media { 24 namespace media {
26 25
27 ACTION(ZeroBuffer) { 26 ACTION(ZeroBuffer) {
28 arg0->Zero(); 27 arg0->Zero();
29 } 28 }
30 29
31 ACTION_P3(MaybeSignalEvent, counter, signal_at_count, event) { 30 ACTION_P(SignalEvent, event) {
32 if (++(*counter) == signal_at_count) 31 event->Signal();
33 event->Signal();
34 } 32 }
35 33
36 class AUHALStreamTest : public testing::Test { 34 class AUHALStreamTest : public testing::Test {
37 public: 35 public:
38 AUHALStreamTest() 36 AUHALStreamTest()
39 : message_loop_(base::MessageLoop::TYPE_UI), 37 : message_loop_(base::MessageLoop::TYPE_UI),
40 manager_(AudioManager::CreateForTesting( 38 manager_(AudioManager::CreateForTesting(
41 base::ThreadTaskRunnerHandle::Get())) { 39 base::ThreadTaskRunnerHandle::Get())) {
42 // Wait for the AudioManager to finish any initialization on the audio loop. 40 // Wait for the AudioManager to finish any initialization on the audio loop.
43 base::RunLoop().RunUntilIdle(); 41 base::RunLoop().RunUntilIdle();
44 } 42 }
45 43
46 ~AUHALStreamTest() override {} 44 ~AUHALStreamTest() override {}
47 45
48 AudioOutputStream* Create() { 46 AudioOutputStream* Create() {
49 return manager_->MakeAudioOutputStream( 47 return manager_->MakeAudioOutputStream(
50 manager_->GetDefaultOutputStreamParameters(), "", 48 manager_->GetDefaultOutputStreamParameters(), "");
51 base::Bind(&AUHALStreamTest::OnLogMessage, base::Unretained(this)));
52 } 49 }
53 50
54 bool OutputDevicesAvailable() { 51 bool OutputDevicesAvailable() {
55 return manager_->HasAudioOutputDevices(); 52 return manager_->HasAudioOutputDevices();
56 } 53 }
57 54
58 void OnLogMessage(const std::string& message) { log_message_ = message; }
59
60 protected: 55 protected:
61 base::TestMessageLoop message_loop_; 56 base::TestMessageLoop message_loop_;
62 ScopedAudioManagerPtr manager_; 57 ScopedAudioManagerPtr manager_;
63 MockAudioSourceCallback source_; 58 MockAudioSourceCallback source_;
64 std::string log_message_;
65 59
66 private: 60 private:
67 DISALLOW_COPY_AND_ASSIGN(AUHALStreamTest); 61 DISALLOW_COPY_AND_ASSIGN(AUHALStreamTest);
68 }; 62 };
69 63
70 TEST_F(AUHALStreamTest, HardwareSampleRate) { 64 TEST_F(AUHALStreamTest, HardwareSampleRate) {
71 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); 65 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable());
72 const AudioParameters preferred_params = 66 const AudioParameters preferred_params =
73 manager_->GetDefaultOutputStreamParameters(); 67 manager_->GetDefaultOutputStreamParameters();
74 EXPECT_GE(preferred_params.sample_rate(), 16000); 68 EXPECT_GE(preferred_params.sample_rate(), 16000);
(...skipping 11 matching lines...) Expand all
86 EXPECT_TRUE(stream->Open()); 80 EXPECT_TRUE(stream->Open());
87 stream->Close(); 81 stream->Close();
88 } 82 }
89 83
90 TEST_F(AUHALStreamTest, CreateOpenStartStopClose) { 84 TEST_F(AUHALStreamTest, CreateOpenStartStopClose) {
91 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); 85 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable());
92 86
93 AudioOutputStream* stream = Create(); 87 AudioOutputStream* stream = Create();
94 EXPECT_TRUE(stream->Open()); 88 EXPECT_TRUE(stream->Open());
95 89
96 // Wait for the first two data callback from the OS. 90 // Wait for the first data callback from the OS.
97 base::WaitableEvent event(false, false); 91 base::WaitableEvent event(false, false);
98 int callback_counter = 0;
99 const int number_of_callbacks = 2;
100 EXPECT_CALL(source_, OnMoreData(_, _, _)) 92 EXPECT_CALL(source_, OnMoreData(_, _, _))
101 .Times(number_of_callbacks) 93 .WillOnce(DoAll(ZeroBuffer(), SignalEvent(&event), Return(0)));
102 .WillRepeatedly(DoAll(
103 ZeroBuffer(),
104 MaybeSignalEvent(&callback_counter, number_of_callbacks, &event),
105 Return(0)));
106 EXPECT_CALL(source_, OnError(_)).Times(0); 94 EXPECT_CALL(source_, OnError(_)).Times(0);
107 stream->Start(&source_); 95 stream->Start(&source_);
108 event.Wait(); 96 event.Wait();
109 97
110 stream->Stop(); 98 stream->Stop();
111 stream->Close(); 99 stream->Close();
112
113 EXPECT_FALSE(log_message_.empty());
114 } 100 }
115 101
116 } // namespace media 102 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/mac/audio_auhal_mac.cc ('k') | media/audio/mac/audio_low_latency_input_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698