Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 #include "webrtc/modules/audio_device/audio_device_impl.h" | 25 #include "webrtc/modules/audio_device/audio_device_impl.h" |
| 26 #include "webrtc/modules/audio_device/include/audio_device.h" | 26 #include "webrtc/modules/audio_device/include/audio_device.h" |
| 27 #include "webrtc/modules/audio_device/include/mock_audio_transport.h" | 27 #include "webrtc/modules/audio_device/include/mock_audio_transport.h" |
| 28 #include "webrtc/modules/audio_device/ios/audio_device_ios.h" | 28 #include "webrtc/modules/audio_device/ios/audio_device_ios.h" |
| 29 #include "webrtc/system_wrappers/include/event_wrapper.h" | 29 #include "webrtc/system_wrappers/include/event_wrapper.h" |
| 30 #include "webrtc/system_wrappers/include/sleep.h" | 30 #include "webrtc/system_wrappers/include/sleep.h" |
| 31 #include "webrtc/test/gmock.h" | 31 #include "webrtc/test/gmock.h" |
| 32 #include "webrtc/test/gtest.h" | 32 #include "webrtc/test/gtest.h" |
| 33 #include "webrtc/test/testsupport/fileutils.h" | 33 #include "webrtc/test/testsupport/fileutils.h" |
| 34 | 34 |
| 35 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h" | |
| 36 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession+Private.h" | |
| 37 | |
| 35 using std::cout; | 38 using std::cout; |
| 36 using std::endl; | 39 using std::endl; |
| 37 using ::testing::_; | 40 using ::testing::_; |
| 38 using ::testing::AtLeast; | 41 using ::testing::AtLeast; |
| 39 using ::testing::Gt; | 42 using ::testing::Gt; |
| 40 using ::testing::Invoke; | 43 using ::testing::Invoke; |
| 41 using ::testing::NiceMock; | 44 using ::testing::NiceMock; |
| 42 using ::testing::NotNull; | 45 using ::testing::NotNull; |
| 43 using ::testing::Return; | 46 using ::testing::Return; |
| 44 | 47 |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 std::max(kTestTimeOutInMilliseconds, 1000 * kMeasureLatencyTimeInSec)); | 818 std::max(kTestTimeOutInMilliseconds, 1000 * kMeasureLatencyTimeInSec)); |
| 816 StopPlayout(); | 819 StopPlayout(); |
| 817 StopRecording(); | 820 StopRecording(); |
| 818 // Verify that the correct number of transmitted impulses are detected. | 821 // Verify that the correct number of transmitted impulses are detected. |
| 819 EXPECT_EQ(latency_audio_stream->num_latency_values(), | 822 EXPECT_EQ(latency_audio_stream->num_latency_values(), |
| 820 static_cast<size_t>( | 823 static_cast<size_t>( |
| 821 kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1)); | 824 kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1)); |
| 822 latency_audio_stream->PrintResults(); | 825 latency_audio_stream->PrintResults(); |
| 823 } | 826 } |
| 824 | 827 |
| 828 TEST_F(AudioDeviceTest, testInterruptedAudioSession) { | |
|
henrika_webrtc
2017/05/10 14:08:19
Care to add some comments above this test to expla
| |
| 829 RTCAudioSession *session = [RTCAudioSession sharedInstance]; | |
| 830 std::unique_ptr<webrtc::AudioDeviceIOS> audio_device; | |
| 831 audio_device.reset(new webrtc::AudioDeviceIOS()); | |
| 832 std::unique_ptr<webrtc::AudioDeviceBuffer> audio_buffer; | |
| 833 audio_buffer.reset(new webrtc::AudioDeviceBuffer()); | |
| 834 audio_device->AttachAudioBuffer(audio_buffer.get()); | |
| 835 audio_device->Init(); | |
| 836 audio_device->InitPlayout(); | |
| 837 // Force interruption. | |
| 838 [session notifyDidBeginInterruption]; | |
| 839 | |
| 840 // Wait for notification to propagate. | |
| 841 rtc::MessageQueueManager::ProcessAllMessageQueues(); | |
| 842 EXPECT_TRUE(audio_device->is_interrupted_); | |
| 843 | |
| 844 // Force it for testing. | |
| 845 audio_device->playing_ = false; | |
| 846 audio_device->ShutdownPlayOrRecord(); | |
| 847 // Force it for testing. | |
| 848 audio_device->audio_is_initialized_ = false; | |
| 849 | |
| 850 [session notifyDidEndInterruptionWithShouldResumeSession:YES]; | |
| 851 // Wait for notification to propagate. | |
| 852 rtc::MessageQueueManager::ProcessAllMessageQueues(); | |
| 853 EXPECT_TRUE(audio_device->is_interrupted_); | |
| 854 | |
| 855 audio_device->Init(); | |
| 856 audio_device->InitPlayout(); | |
| 857 EXPECT_FALSE(audio_device->is_interrupted_); | |
| 858 } | |
| 859 | |
| 825 } // namespace webrtc | 860 } // namespace webrtc |
| OLD | NEW |