| 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..c050e314c99ee681b8a070aa33e9a53a89e6c013 100644
|
| --- a/webrtc/modules/audio_device/ios/objc/RTCAudioSessionTest.mm
|
| +++ b/webrtc/modules/audio_device/ios/objc/RTCAudioSessionTest.mm
|
| @@ -18,10 +18,22 @@
|
| #import "webrtc/modules/audio_device/ios/objc/RTCAudioSessionConfiguration.h"
|
|
|
| @interface RTCAudioSessionTestDelegate : NSObject <RTCAudioSessionDelegate>
|
| +
|
| +@property (nonatomic, readonly) float outputVolume;
|
| +
|
| @end
|
|
|
| @implementation RTCAudioSessionTestDelegate
|
|
|
| +@synthesize outputVolume = _outputVolume;
|
| +
|
| +- (instancetype)init {
|
| + if (self = [super init]) {
|
| + _outputVolume = -1;
|
| + }
|
| + return self;
|
| +}
|
| +
|
| - (void)audioSessionDidBeginInterruption:(RTCAudioSession *)session {
|
| }
|
|
|
| @@ -46,6 +58,11 @@
|
| - (void)audioSessionShouldUnconfigure:(RTCAudioSession *)session {
|
| }
|
|
|
| +- (void)audioSession:(RTCAudioSession *)audioSession
|
| + didChangeOutputVolume:(float)outputVolume {
|
| + _outputVolume = outputVolume;
|
| +}
|
| +
|
| @end
|
|
|
| // A delegate that adds itself to the audio session on init and removes itself
|
| @@ -246,6 +263,23 @@ OCMLocation *OCMMakeLocation(id testCase, const char *fileCString, int line){
|
| [mockAudioSession stopMocking];
|
| }
|
|
|
| +- (void)testAudioVolumeDidNotify {
|
| + RTCAudioSession *session = [RTCAudioSession sharedInstance];
|
| + RTCAudioSessionTestDelegate *delegate =
|
| + [[RTCAudioSessionTestDelegate alloc] init];
|
| + [session addDelegate:delegate];
|
| +
|
| + [session observeValueForKeyPath:@"outputVolume"
|
| + ofObject:[AVAudioSession sharedInstance]
|
| + change:
|
| + @{NSKeyValueChangeNewKey :
|
| + @([AVAudioSession sharedInstance].outputVolume) }
|
| + context:nil];
|
| +
|
| + EXPECT_NE(delegate.outputVolume, -1);
|
| + EXPECT_EQ([AVAudioSession sharedInstance].outputVolume, delegate.outputVolume);
|
| +}
|
| +
|
| @end
|
|
|
| namespace webrtc {
|
| @@ -295,4 +329,9 @@ TEST_F(AudioSessionTest, ConfigureWebRTCSession) {
|
| [test testConfigureWebRTCSession];
|
| }
|
|
|
| +TEST_F(AudioSessionTest, AudioVolumeDidNotify) {
|
| + RTCAudioSessionTest *test = [[RTCAudioSessionTest alloc] init];
|
| + [test testAudioVolumeDidNotify];
|
| +}
|
| +
|
| } // namespace webrtc
|
|
|