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

Side by Side Diff: webrtc/modules/audio_device/ios/audio_device_unittest_ios.mm

Issue 2872953002: iOS audio session isInterrupted flag does not get reset correctly: (Closed)
Patch Set: Added gtest dependency Created 3 years, 7 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 | « webrtc/modules/audio_device/ios/audio_device_unittest_ios.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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) {
829 RTCAudioSession *session = [RTCAudioSession sharedInstance];
830 std::unique_ptr<webrtc::AudioDeviceIOS> audioDevice;
tkchin_webrtc 2017/05/09 21:07:02 use C++ style in C++ file. underscores.
831 audioDevice.reset(new webrtc::AudioDeviceIOS());
832 std::unique_ptr<webrtc::AudioDeviceBuffer> audioBuffer;
tkchin_webrtc 2017/05/09 21:07:02 There are several methods in this test file alread
833 audioBuffer.reset(new webrtc::AudioDeviceBuffer());
834 audioDevice->AttachAudioBuffer(audioBuffer.get());
835 audioDevice->Init();
836 audioDevice->InitPlayout();
837 [session notifyDidBeginInterruption]; // force interruption
tkchin_webrtc 2017/05/09 21:07:02 nit: we typically do not comment inline, move comm
838
839 // Wait for notification to propagate
840 rtc::MessageQueueManager::ProcessAllMessageQueues();
841 EXPECT_TRUE(audioDevice->is_interrupted_);
842
843 audioDevice->playing_ = false; // force it for testing
844 audioDevice->ShutdownPlayOrRecord();
845 audioDevice->audio_is_initialized_ = false; // force it for testing
846
847 [session notifyDidEndInterruptionWithShouldResumeSession:YES];
848 // Wait for notification to propagate
849 rtc::MessageQueueManager::ProcessAllMessageQueues();
850 EXPECT_TRUE(audioDevice->is_interrupted_);
851
852 audioDevice->Init();
853 audioDevice->InitPlayout();
854 EXPECT_FALSE(audioDevice->is_interrupted_);
855 }
856
825 } // namespace webrtc 857 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/ios/audio_device_unittest_ios.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698