OLD | NEW |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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/memory/ptr_util.h" | 5 #include "base/memory/ptr_util.h" |
6 #include "base/memory/shared_memory.h" | 6 #include "base/memory/shared_memory.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/process/process_handle.h" | 8 #include "base/process/process_handle.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 MockAudioInputIPC* input_ipc = new MockAudioInputIPC(); | 86 MockAudioInputIPC* input_ipc = new MockAudioInputIPC(); |
87 scoped_refptr<AudioInputDevice> device( | 87 scoped_refptr<AudioInputDevice> device( |
88 new AudioInputDevice(base::WrapUnique(input_ipc), io_loop.task_runner())); | 88 new AudioInputDevice(base::WrapUnique(input_ipc), io_loop.task_runner())); |
89 device->Initialize(params, &callback, 1); | 89 device->Initialize(params, &callback, 1); |
90 device->Start(); | 90 device->Start(); |
91 EXPECT_CALL(*input_ipc, CreateStream(_, _, _, _, _)) | 91 EXPECT_CALL(*input_ipc, CreateStream(_, _, _, _, _)) |
92 .WillOnce(ReportStateChange(device.get())); | 92 .WillOnce(ReportStateChange(device.get())); |
93 EXPECT_CALL(callback, OnCaptureError(_)) | 93 EXPECT_CALL(callback, OnCaptureError(_)) |
94 .WillOnce(QuitLoop(io_loop.task_runner())); | 94 .WillOnce(QuitLoop(io_loop.task_runner())); |
95 base::RunLoop().Run(); | 95 base::RunLoop().Run(); |
| 96 device->Stop(); |
| 97 base::RunLoop().RunUntilIdle(); |
96 } | 98 } |
97 | 99 |
98 ACTION_P5(ReportOnStreamCreated, device, handle, socket, length, segments) { | 100 ACTION_P5(ReportOnStreamCreated, device, handle, socket, length, segments) { |
99 static_cast<AudioInputIPCDelegate*>(device)->OnStreamCreated( | 101 static_cast<AudioInputIPCDelegate*>(device)->OnStreamCreated( |
100 handle, socket, length, segments); | 102 handle, socket, length, segments); |
101 } | 103 } |
102 | 104 |
103 TEST(AudioInputDeviceTest, CreateStream) { | 105 TEST(AudioInputDeviceTest, CreateStream) { |
104 AudioParameters params(AudioParameters::AUDIO_PCM_LOW_LATENCY, | 106 AudioParameters params(AudioParameters::AUDIO_PCM_LOW_LATENCY, |
105 CHANNEL_LAYOUT_STEREO, 48000, 16, 480); | 107 CHANNEL_LAYOUT_STEREO, 48000, 16, 480); |
(...skipping 26 matching lines...) Expand all Loading... |
132 | 134 |
133 EXPECT_CALL(*input_ipc, CreateStream(_, _, _, _, _)) | 135 EXPECT_CALL(*input_ipc, CreateStream(_, _, _, _, _)) |
134 .WillOnce(ReportOnStreamCreated( | 136 .WillOnce(ReportOnStreamCreated( |
135 device.get(), duplicated_memory_handle, | 137 device.get(), duplicated_memory_handle, |
136 SyncSocket::UnwrapHandle(audio_device_socket_descriptor), memory_size, | 138 SyncSocket::UnwrapHandle(audio_device_socket_descriptor), memory_size, |
137 1)); | 139 1)); |
138 EXPECT_CALL(*input_ipc, RecordStream()); | 140 EXPECT_CALL(*input_ipc, RecordStream()); |
139 EXPECT_CALL(callback, OnCaptureStarted()) | 141 EXPECT_CALL(callback, OnCaptureStarted()) |
140 .WillOnce(QuitLoop(io_loop.task_runner())); | 142 .WillOnce(QuitLoop(io_loop.task_runner())); |
141 base::RunLoop().Run(); | 143 base::RunLoop().Run(); |
| 144 device->Stop(); |
| 145 base::RunLoop().RunUntilIdle(); |
142 } | 146 } |
| 147 |
143 } // namespace media. | 148 } // namespace media. |
OLD | NEW |