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

Unified Diff: webrtc/modules/audio_device/ios/objc/RTCAudioSessionTest.mm

Issue 2872953002: iOS audio session isInterrupted flag does not get reset correctly: (Closed)
Patch Set: Merge branch 'master' of https://chromium.googlesource.com/external/webrtc into interrupt 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/audio_device/ios/audio_device_ios.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_device/ios/objc/RTCAudioSessionTest.mm
diff --git a/webrtc/modules/audio_device/ios/objc/RTCAudioSessionTest.mm b/webrtc/modules/audio_device/ios/objc/RTCAudioSessionTest.mm
index a4b49fc1c08129fb4f3f2a1ba0b12397769a9b87..1793e01610be1e2dd72a34b881c7328638b2eb39 100644
--- a/webrtc/modules/audio_device/ios/objc/RTCAudioSessionTest.mm
+++ b/webrtc/modules/audio_device/ios/objc/RTCAudioSessionTest.mm
@@ -11,6 +11,9 @@
#import <Foundation/Foundation.h>
#import <OCMock/OCMock.h>
+// Allow private members to be accessed for testing purposes
+#define private public
tkchin_webrtc 2017/05/09 17:48:25 oof. Don't do this - not good to redefine keywords
+#include "webrtc/modules/audio_device/ios/audio_device_ios.h"
#include "webrtc/test/gtest.h"
#import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h"
@@ -246,6 +249,35 @@ OCMLocation *OCMMakeLocation(id testCase, const char *fileCString, int line){
[mockAudioSession stopMocking];
}
+- (void)testInterruptedAudioSession {
tkchin_webrtc 2017/05/09 17:48:25 this belongs in: https://cs.chromium.org/chromium/
+ RTCAudioSession *session = [RTCAudioSession sharedInstance];
+ webrtc::AudioDeviceIOS *audioDevice = new webrtc::AudioDeviceIOS();
+ webrtc::AudioDeviceBuffer *audioBuffer = new webrtc::AudioDeviceBuffer();
+ audioDevice->AttachAudioBuffer(audioBuffer);
+ audioDevice->Init();
+ audioDevice->InitPlayout();
+ [session notifyDidBeginInterruption]; // force interruption
+
+ // Wait for notification to propagate
+ rtc::MessageQueueManager::ProcessAllMessageQueues();
+ EXPECT_TRUE(audioDevice->is_interrupted_);
+
+ audioDevice->playing_ = false; // force it for testing
+ audioDevice->ShutdownPlayOrRecord();
+ audioDevice->audio_is_initialized_ = false; // force it for testing
+
+ [session notifyDidEndInterruptionWithShouldResumeSession:YES];
+ // Wait for notification to propagate
+ rtc::MessageQueueManager::ProcessAllMessageQueues();
+ EXPECT_TRUE(audioDevice->is_interrupted_);
+
+ audioDevice->Init();
+ audioDevice->InitPlayout();
+ EXPECT_FALSE(audioDevice->is_interrupted_);
+ delete audioBuffer;
tkchin_webrtc 2017/05/09 17:48:25 fyi it is extremely rare to use delete now since u
jtt_webrtc 2017/05/09 19:07:45 Done.
+ delete audioDevice;
+}
+
@end
namespace webrtc {
@@ -295,4 +327,9 @@ TEST_F(AudioSessionTest, ConfigureWebRTCSession) {
[test testConfigureWebRTCSession];
}
+TEST_F(AudioSessionTest, testInterruptedAudioSession) {
+ RTCAudioSessionTest *test = [[RTCAudioSessionTest alloc] init];
+ [test testInterruptedAudioSession];
+}
+
} // namespace webrtc
« no previous file with comments | « webrtc/modules/audio_device/ios/audio_device_ios.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698