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

Side by Side Diff: media/audio/cras/cras_input_unittest.cc

Issue 2689483006: Switch browser side audio capture path to use base time primitives. (Closed)
Patch Set: Bloop Created 3 years, 10 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
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 18 matching lines...) Expand all
29 using testing::_; 29 using testing::_;
30 using testing::AtLeast; 30 using testing::AtLeast;
31 using testing::Ge; 31 using testing::Ge;
32 using testing::InvokeWithoutArgs; 32 using testing::InvokeWithoutArgs;
33 using testing::StrictMock; 33 using testing::StrictMock;
34 34
35 namespace media { 35 namespace media {
36 36
37 class MockAudioInputCallback : public AudioInputStream::AudioInputCallback { 37 class MockAudioInputCallback : public AudioInputStream::AudioInputCallback {
38 public: 38 public:
39 MOCK_METHOD4(OnData, 39 MOCK_METHOD5(OnData,
40 void(AudioInputStream*, const AudioBus*, uint32_t, double)); 40 void(AudioInputStream*,
41 const AudioBus*,
42 base::TimeDelta,
43 base::TimeTicks,
44 double));
41 MOCK_METHOD1(OnError, void(AudioInputStream*)); 45 MOCK_METHOD1(OnError, void(AudioInputStream*));
42 }; 46 };
43 47
44 class MockAudioManagerCrasInput : public AudioManagerCras { 48 class MockAudioManagerCrasInput : public AudioManagerCras {
45 public: 49 public:
46 MockAudioManagerCrasInput() 50 MockAudioManagerCrasInput()
47 : AudioManagerCras(base::ThreadTaskRunnerHandle::Get(), 51 : AudioManagerCras(base::ThreadTaskRunnerHandle::Get(),
48 base::ThreadTaskRunnerHandle::Get(), 52 base::ThreadTaskRunnerHandle::Get(),
49 &fake_audio_log_factory_) {} 53 &fake_audio_log_factory_) {}
50 54
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 102
99 ASSERT_TRUE(test_stream->Open()); 103 ASSERT_TRUE(test_stream->Open());
100 104
101 // Allow 8 frames variance for SRC in the callback. Different numbers of 105 // Allow 8 frames variance for SRC in the callback. Different numbers of
102 // samples can be provided when doing non-integer SRC. For example 106 // samples can be provided when doing non-integer SRC. For example
103 // converting from 192k to 44.1k is a ratio of 4.35 to 1. 107 // converting from 192k to 44.1k is a ratio of 4.35 to 1.
104 MockAudioInputCallback mock_callback; 108 MockAudioInputCallback mock_callback;
105 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, 109 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
106 base::WaitableEvent::InitialState::NOT_SIGNALED); 110 base::WaitableEvent::InitialState::NOT_SIGNALED);
107 111
108 EXPECT_CALL(mock_callback, OnData(test_stream, _, _, _)) 112 EXPECT_CALL(mock_callback, OnData(test_stream, _, _, _, _))
109 .WillOnce(InvokeWithoutArgs(&event, &base::WaitableEvent::Signal)); 113 .WillOnce(InvokeWithoutArgs(&event, &base::WaitableEvent::Signal));
110 114
111 test_stream->Start(&mock_callback); 115 test_stream->Start(&mock_callback);
112 116
113 // Wait for samples to be captured. 117 // Wait for samples to be captured.
114 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout())); 118 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout()));
115 119
116 test_stream->Stop(); 120 test_stream->Stop();
117 test_stream->Close(); 121 test_stream->Close();
118 } 122 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 227
224 TEST_F(CrasInputStreamTest, CaptureLoopback) { 228 TEST_F(CrasInputStreamTest, CaptureLoopback) {
225 CrasInputStream* test_stream = 229 CrasInputStream* test_stream =
226 CreateStream(CHANNEL_LAYOUT_STEREO, kTestFramesPerPacket, 230 CreateStream(CHANNEL_LAYOUT_STEREO, kTestFramesPerPacket,
227 AudioDeviceDescription::kLoopbackInputDeviceId); 231 AudioDeviceDescription::kLoopbackInputDeviceId);
228 EXPECT_TRUE(test_stream->Open()); 232 EXPECT_TRUE(test_stream->Open());
229 test_stream->Close(); 233 test_stream->Close();
230 } 234 }
231 235
232 } // namespace media 236 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698