tkchin | 0ce3bf9 | 2016-03-12 16:52:04 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #import <Foundation/Foundation.h> |
jtteh | f84c1d6 | 2017-04-21 13:56:39 -0700 | [diff] [blame] | 12 | #import <OCMock/OCMock.h> |
Byoungchan Lee | c8a6fb2 | 2022-05-13 19:59:49 +0900 | [diff] [blame] | 13 | #import <XCTest/XCTest.h> |
tkchin | 0ce3bf9 | 2016-03-12 16:52:04 -0800 | [diff] [blame] | 14 | |
Joe Chen | 0b3a6e3 | 2019-12-26 23:01:42 -0800 | [diff] [blame] | 15 | #include <vector> |
| 16 | |
Byoungchan Lee | 0a54e7a | 2021-09-06 22:32:52 +0900 | [diff] [blame] | 17 | #include "rtc_base/event.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "rtc_base/gunit.h" |
tkchin | 0ce3bf9 | 2016-03-12 16:52:04 -0800 | [diff] [blame] | 19 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 20 | #import "components/audio/RTCAudioSession+Private.h" |
denicija | 59ee91b | 2017-06-05 05:48:47 -0700 | [diff] [blame] | 21 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 22 | #import "components/audio/RTCAudioSession.h" |
| 23 | #import "components/audio/RTCAudioSessionConfiguration.h" |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 24 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 25 | @interface RTC_OBJC_TYPE (RTCAudioSession) |
| 26 | (UnitTesting) |
Peter Hanspers | 4721736 | 2017-10-05 11:39:15 +0200 | [diff] [blame] | 27 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 28 | @property(nonatomic, |
| 29 | readonly) std::vector<__weak id<RTC_OBJC_TYPE(RTCAudioSessionDelegate)> > delegates; |
Joe Chen | 0b3a6e3 | 2019-12-26 23:01:42 -0800 | [diff] [blame] | 30 | |
Peter Hanspers | 4721736 | 2017-10-05 11:39:15 +0200 | [diff] [blame] | 31 | - (instancetype)initWithAudioSession:(id)audioSession; |
| 32 | |
| 33 | @end |
| 34 | |
| 35 | @interface MockAVAudioSession : NSObject |
| 36 | |
| 37 | @property (nonatomic, readwrite, assign) float outputVolume; |
| 38 | |
| 39 | @end |
| 40 | |
| 41 | @implementation MockAVAudioSession |
| 42 | @synthesize outputVolume = _outputVolume; |
| 43 | @end |
| 44 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 45 | @interface RTCAudioSessionTestDelegate : NSObject <RTC_OBJC_TYPE (RTCAudioSessionDelegate)> |
jtteh | 13ae11a | 2017-05-25 17:52:20 -0700 | [diff] [blame] | 46 | |
| 47 | @property (nonatomic, readonly) float outputVolume; |
| 48 | |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 49 | @end |
| 50 | |
| 51 | @implementation RTCAudioSessionTestDelegate |
| 52 | |
jtteh | 13ae11a | 2017-05-25 17:52:20 -0700 | [diff] [blame] | 53 | @synthesize outputVolume = _outputVolume; |
| 54 | |
| 55 | - (instancetype)init { |
| 56 | if (self = [super init]) { |
| 57 | _outputVolume = -1; |
| 58 | } |
| 59 | return self; |
| 60 | } |
| 61 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 62 | - (void)audioSessionDidBeginInterruption:(RTC_OBJC_TYPE(RTCAudioSession) *)session { |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 65 | - (void)audioSessionDidEndInterruption:(RTC_OBJC_TYPE(RTCAudioSession) *)session |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 66 | shouldResumeSession:(BOOL)shouldResumeSession { |
| 67 | } |
| 68 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 69 | - (void)audioSessionDidChangeRoute:(RTC_OBJC_TYPE(RTCAudioSession) *)session |
| 70 | reason:(AVAudioSessionRouteChangeReason)reason |
| 71 | previousRoute:(AVAudioSessionRouteDescription *)previousRoute { |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 72 | } |
| 73 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 74 | - (void)audioSessionMediaServerTerminated:(RTC_OBJC_TYPE(RTCAudioSession) *)session { |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 77 | - (void)audioSessionMediaServerReset:(RTC_OBJC_TYPE(RTCAudioSession) *)session { |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 80 | - (void)audioSessionShouldConfigure:(RTC_OBJC_TYPE(RTCAudioSession) *)session { |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 83 | - (void)audioSessionShouldUnconfigure:(RTC_OBJC_TYPE(RTCAudioSession) *)session { |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 86 | - (void)audioSession:(RTC_OBJC_TYPE(RTCAudioSession) *)audioSession |
jtteh | 13ae11a | 2017-05-25 17:52:20 -0700 | [diff] [blame] | 87 | didChangeOutputVolume:(float)outputVolume { |
| 88 | _outputVolume = outputVolume; |
| 89 | } |
| 90 | |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 91 | @end |
| 92 | |
tkchin | efdd930 | 2016-04-11 12:00:59 -0700 | [diff] [blame] | 93 | // A delegate that adds itself to the audio session on init and removes itself |
| 94 | // in its dealloc. |
| 95 | @interface RTCTestRemoveOnDeallocDelegate : RTCAudioSessionTestDelegate |
| 96 | @end |
| 97 | |
| 98 | @implementation RTCTestRemoveOnDeallocDelegate |
| 99 | |
| 100 | - (instancetype)init { |
| 101 | if (self = [super init]) { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 102 | RTC_OBJC_TYPE(RTCAudioSession) *session = [RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]; |
tkchin | efdd930 | 2016-04-11 12:00:59 -0700 | [diff] [blame] | 103 | [session addDelegate:self]; |
| 104 | } |
| 105 | return self; |
| 106 | } |
| 107 | |
| 108 | - (void)dealloc { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 109 | RTC_OBJC_TYPE(RTCAudioSession) *session = [RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]; |
tkchin | efdd930 | 2016-04-11 12:00:59 -0700 | [diff] [blame] | 110 | [session removeDelegate:self]; |
| 111 | } |
| 112 | |
| 113 | @end |
| 114 | |
Byoungchan Lee | c8a6fb2 | 2022-05-13 19:59:49 +0900 | [diff] [blame] | 115 | @interface RTCAudioSessionTest : XCTestCase |
tkchin | 0ce3bf9 | 2016-03-12 16:52:04 -0800 | [diff] [blame] | 116 | |
tkchin | 0ce3bf9 | 2016-03-12 16:52:04 -0800 | [diff] [blame] | 117 | @end |
| 118 | |
| 119 | @implementation RTCAudioSessionTest |
| 120 | |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 121 | - (void)testAddAndRemoveDelegates { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 122 | RTC_OBJC_TYPE(RTCAudioSession) *session = [RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]; |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 123 | NSMutableArray *delegates = [NSMutableArray array]; |
| 124 | const size_t count = 5; |
| 125 | for (size_t i = 0; i < count; ++i) { |
| 126 | RTCAudioSessionTestDelegate *delegate = |
| 127 | [[RTCAudioSessionTestDelegate alloc] init]; |
| 128 | [session addDelegate:delegate]; |
| 129 | [delegates addObject:delegate]; |
| 130 | EXPECT_EQ(i + 1, session.delegates.size()); |
| 131 | } |
| 132 | [delegates enumerateObjectsUsingBlock:^(RTCAudioSessionTestDelegate *obj, |
| 133 | NSUInteger idx, |
| 134 | BOOL *stop) { |
| 135 | [session removeDelegate:obj]; |
| 136 | }]; |
| 137 | EXPECT_EQ(0u, session.delegates.size()); |
| 138 | } |
| 139 | |
| 140 | - (void)testPushDelegate { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 141 | RTC_OBJC_TYPE(RTCAudioSession) *session = [RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]; |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 142 | NSMutableArray *delegates = [NSMutableArray array]; |
| 143 | const size_t count = 2; |
| 144 | for (size_t i = 0; i < count; ++i) { |
| 145 | RTCAudioSessionTestDelegate *delegate = |
| 146 | [[RTCAudioSessionTestDelegate alloc] init]; |
| 147 | [session addDelegate:delegate]; |
| 148 | [delegates addObject:delegate]; |
| 149 | } |
| 150 | // Test that it gets added to the front of the list. |
| 151 | RTCAudioSessionTestDelegate *pushedDelegate = |
| 152 | [[RTCAudioSessionTestDelegate alloc] init]; |
| 153 | [session pushDelegate:pushedDelegate]; |
| 154 | EXPECT_TRUE(pushedDelegate == session.delegates[0]); |
| 155 | |
| 156 | // Test that it stays at the front of the list. |
| 157 | for (size_t i = 0; i < count; ++i) { |
| 158 | RTCAudioSessionTestDelegate *delegate = |
| 159 | [[RTCAudioSessionTestDelegate alloc] init]; |
| 160 | [session addDelegate:delegate]; |
| 161 | [delegates addObject:delegate]; |
| 162 | } |
| 163 | EXPECT_TRUE(pushedDelegate == session.delegates[0]); |
| 164 | |
| 165 | // Test that the next one goes to the front too. |
| 166 | pushedDelegate = [[RTCAudioSessionTestDelegate alloc] init]; |
| 167 | [session pushDelegate:pushedDelegate]; |
| 168 | EXPECT_TRUE(pushedDelegate == session.delegates[0]); |
| 169 | } |
| 170 | |
| 171 | // Tests that delegates added to the audio session properly zero out. This is |
| 172 | // checking an implementation detail (that vectors of __weak work as expected). |
| 173 | - (void)testZeroingWeakDelegate { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 174 | RTC_OBJC_TYPE(RTCAudioSession) *session = [RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]; |
tkchin | e54467f | 2016-03-15 16:54:03 -0700 | [diff] [blame] | 175 | @autoreleasepool { |
| 176 | // Add a delegate to the session. There should be one delegate at this |
| 177 | // point. |
| 178 | RTCAudioSessionTestDelegate *delegate = |
| 179 | [[RTCAudioSessionTestDelegate alloc] init]; |
| 180 | [session addDelegate:delegate]; |
| 181 | EXPECT_EQ(1u, session.delegates.size()); |
| 182 | EXPECT_TRUE(session.delegates[0]); |
| 183 | } |
| 184 | // The previously created delegate should've de-alloced, leaving a nil ptr. |
| 185 | EXPECT_FALSE(session.delegates[0]); |
| 186 | RTCAudioSessionTestDelegate *delegate = |
| 187 | [[RTCAudioSessionTestDelegate alloc] init]; |
| 188 | [session addDelegate:delegate]; |
| 189 | // On adding a new delegate, nil ptrs should've been cleared. |
| 190 | EXPECT_EQ(1u, session.delegates.size()); |
| 191 | EXPECT_TRUE(session.delegates[0]); |
| 192 | } |
| 193 | |
tkchin | efdd930 | 2016-04-11 12:00:59 -0700 | [diff] [blame] | 194 | // Tests that we don't crash when removing delegates in dealloc. |
| 195 | // Added as a regression test. |
| 196 | - (void)testRemoveDelegateOnDealloc { |
| 197 | @autoreleasepool { |
| 198 | RTCTestRemoveOnDeallocDelegate *delegate = |
| 199 | [[RTCTestRemoveOnDeallocDelegate alloc] init]; |
| 200 | EXPECT_TRUE(delegate); |
| 201 | } |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 202 | RTC_OBJC_TYPE(RTCAudioSession) *session = [RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]; |
tkchin | efdd930 | 2016-04-11 12:00:59 -0700 | [diff] [blame] | 203 | EXPECT_EQ(0u, session.delegates.size()); |
| 204 | } |
| 205 | |
jtteh | 3c9a6c0 | 2017-04-18 09:09:35 -0700 | [diff] [blame] | 206 | - (void)testAudioSessionActivation { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 207 | RTC_OBJC_TYPE(RTCAudioSession) *audioSession = [RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]; |
jtteh | 3c9a6c0 | 2017-04-18 09:09:35 -0700 | [diff] [blame] | 208 | EXPECT_EQ(0, audioSession.activationCount); |
| 209 | [audioSession audioSessionDidActivate:[AVAudioSession sharedInstance]]; |
| 210 | EXPECT_EQ(1, audioSession.activationCount); |
| 211 | [audioSession audioSessionDidDeactivate:[AVAudioSession sharedInstance]]; |
| 212 | EXPECT_EQ(0, audioSession.activationCount); |
| 213 | } |
| 214 | |
jtteh | f84c1d6 | 2017-04-21 13:56:39 -0700 | [diff] [blame] | 215 | // Hack - fixes OCMVerify link error |
| 216 | // Link error is: Undefined symbols for architecture i386: |
| 217 | // "OCMMakeLocation(objc_object*, char const*, int)", referenced from: |
| 218 | // -[RTCAudioSessionTest testConfigureWebRTCSession] in RTCAudioSessionTest.o |
| 219 | // ld: symbol(s) not found for architecture i386 |
| 220 | // REASON: https://github.com/erikdoe/ocmock/issues/238 |
| 221 | OCMLocation *OCMMakeLocation(id testCase, const char *fileCString, int line){ |
| 222 | return [OCMLocation locationWithTestCase:testCase |
| 223 | file:[NSString stringWithUTF8String:fileCString] |
| 224 | line:line]; |
| 225 | } |
| 226 | |
| 227 | - (void)testConfigureWebRTCSession { |
| 228 | NSError *error = nil; |
| 229 | |
| 230 | void (^setActiveBlock)(NSInvocation *invocation) = ^(NSInvocation *invocation) { |
| 231 | __autoreleasing NSError **retError; |
| 232 | [invocation getArgument:&retError atIndex:4]; |
| 233 | *retError = [NSError errorWithDomain:@"AVAudioSession" |
Björn Terelius | 02768ae | 2021-07-02 16:19:32 +0200 | [diff] [blame] | 234 | code:AVAudioSessionErrorCodeCannotInterruptOthers |
jtteh | f84c1d6 | 2017-04-21 13:56:39 -0700 | [diff] [blame] | 235 | userInfo:nil]; |
| 236 | BOOL failure = NO; |
| 237 | [invocation setReturnValue:&failure]; |
| 238 | }; |
| 239 | |
| 240 | id mockAVAudioSession = OCMPartialMock([AVAudioSession sharedInstance]); |
Mirko Bonadei | ad8a00d | 2021-02-10 09:23:03 +0100 | [diff] [blame] | 241 | OCMStub([[mockAVAudioSession ignoringNonObjectArgs] setActive:YES |
| 242 | withOptions:0 |
| 243 | error:([OCMArg anyObjectRef])]) |
| 244 | .andDo(setActiveBlock); |
jtteh | f84c1d6 | 2017-04-21 13:56:39 -0700 | [diff] [blame] | 245 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 246 | id mockAudioSession = OCMPartialMock([RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]); |
jtteh | f84c1d6 | 2017-04-21 13:56:39 -0700 | [diff] [blame] | 247 | OCMStub([mockAudioSession session]).andReturn(mockAVAudioSession); |
| 248 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 249 | RTC_OBJC_TYPE(RTCAudioSession) *audioSession = mockAudioSession; |
jtteh | f84c1d6 | 2017-04-21 13:56:39 -0700 | [diff] [blame] | 250 | EXPECT_EQ(0, audioSession.activationCount); |
| 251 | [audioSession lockForConfiguration]; |
jtteh | f84c1d6 | 2017-04-21 13:56:39 -0700 | [diff] [blame] | 252 | // configureWebRTCSession is forced to fail in the above mock interface, |
| 253 | // so activationCount should remain 0 |
Mirko Bonadei | ad8a00d | 2021-02-10 09:23:03 +0100 | [diff] [blame] | 254 | OCMExpect([[mockAVAudioSession ignoringNonObjectArgs] setActive:YES |
| 255 | withOptions:0 |
| 256 | error:([OCMArg anyObjectRef])]) |
| 257 | .andDo(setActiveBlock); |
jtteh | f84c1d6 | 2017-04-21 13:56:39 -0700 | [diff] [blame] | 258 | OCMExpect([mockAudioSession session]).andReturn(mockAVAudioSession); |
| 259 | EXPECT_FALSE([audioSession configureWebRTCSession:&error]); |
| 260 | EXPECT_EQ(0, audioSession.activationCount); |
| 261 | |
| 262 | id session = audioSession.session; |
| 263 | EXPECT_EQ(session, mockAVAudioSession); |
| 264 | EXPECT_EQ(NO, [mockAVAudioSession setActive:YES withOptions:0 error:&error]); |
| 265 | [audioSession unlockForConfiguration]; |
| 266 | |
| 267 | OCMVerify([mockAudioSession session]); |
| 268 | OCMVerify([[mockAVAudioSession ignoringNonObjectArgs] setActive:YES withOptions:0 error:&error]); |
| 269 | OCMVerify([[mockAVAudioSession ignoringNonObjectArgs] setActive:NO withOptions:0 error:&error]); |
| 270 | |
| 271 | [mockAVAudioSession stopMocking]; |
| 272 | [mockAudioSession stopMocking]; |
| 273 | } |
| 274 | |
Byoungchan Lee | 0a54e7a | 2021-09-06 22:32:52 +0900 | [diff] [blame] | 275 | - (void)testConfigureWebRTCSessionWithoutLocking { |
| 276 | NSError *error = nil; |
| 277 | |
| 278 | id mockAVAudioSession = OCMPartialMock([AVAudioSession sharedInstance]); |
| 279 | id mockAudioSession = OCMPartialMock([RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]); |
| 280 | OCMStub([mockAudioSession session]).andReturn(mockAVAudioSession); |
| 281 | |
| 282 | RTC_OBJC_TYPE(RTCAudioSession) *audioSession = mockAudioSession; |
| 283 | |
| 284 | std::unique_ptr<rtc::Thread> thread = rtc::Thread::Create(); |
| 285 | EXPECT_TRUE(thread); |
| 286 | EXPECT_TRUE(thread->Start()); |
| 287 | |
| 288 | rtc::Event waitLock; |
| 289 | rtc::Event waitCleanup; |
| 290 | constexpr int timeoutMs = 5000; |
Henrik Boström | 2deee4b | 2022-01-20 11:58:05 +0100 | [diff] [blame] | 291 | thread->PostTask([audioSession, &waitLock, &waitCleanup] { |
Byoungchan Lee | 0a54e7a | 2021-09-06 22:32:52 +0900 | [diff] [blame] | 292 | [audioSession lockForConfiguration]; |
| 293 | waitLock.Set(); |
| 294 | waitCleanup.Wait(timeoutMs); |
| 295 | [audioSession unlockForConfiguration]; |
| 296 | }); |
| 297 | |
| 298 | waitLock.Wait(timeoutMs); |
| 299 | [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:0 error:&error]; |
| 300 | EXPECT_TRUE(error != nil); |
| 301 | EXPECT_EQ(error.domain, kRTCAudioSessionErrorDomain); |
| 302 | EXPECT_EQ(error.code, kRTCAudioSessionErrorLockRequired); |
| 303 | waitCleanup.Set(); |
| 304 | thread->Stop(); |
| 305 | |
| 306 | [mockAVAudioSession stopMocking]; |
| 307 | [mockAudioSession stopMocking]; |
| 308 | } |
| 309 | |
jtteh | 13ae11a | 2017-05-25 17:52:20 -0700 | [diff] [blame] | 310 | - (void)testAudioVolumeDidNotify { |
Peter Hanspers | 4721736 | 2017-10-05 11:39:15 +0200 | [diff] [blame] | 311 | MockAVAudioSession *mockAVAudioSession = [[MockAVAudioSession alloc] init]; |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 312 | RTC_OBJC_TYPE(RTCAudioSession) *session = |
| 313 | [[RTC_OBJC_TYPE(RTCAudioSession) alloc] initWithAudioSession:mockAVAudioSession]; |
jtteh | 13ae11a | 2017-05-25 17:52:20 -0700 | [diff] [blame] | 314 | RTCAudioSessionTestDelegate *delegate = |
| 315 | [[RTCAudioSessionTestDelegate alloc] init]; |
| 316 | [session addDelegate:delegate]; |
| 317 | |
Peter Hanspers | 4721736 | 2017-10-05 11:39:15 +0200 | [diff] [blame] | 318 | float expectedVolume = 0.75; |
| 319 | mockAVAudioSession.outputVolume = expectedVolume; |
jtteh | 13ae11a | 2017-05-25 17:52:20 -0700 | [diff] [blame] | 320 | |
Peter Hanspers | 4721736 | 2017-10-05 11:39:15 +0200 | [diff] [blame] | 321 | EXPECT_EQ(expectedVolume, delegate.outputVolume); |
jtteh | 13ae11a | 2017-05-25 17:52:20 -0700 | [diff] [blame] | 322 | } |
| 323 | |
tkchin | 0ce3bf9 | 2016-03-12 16:52:04 -0800 | [diff] [blame] | 324 | @end |