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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2016 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
11 #import <Foundation/Foundation.h> 11 #import <Foundation/Foundation.h>
12 #import <OCMock/OCMock.h> 12 #import <OCMock/OCMock.h>
13 13
14 // Allow private members to be accessed for testing purposes
15 #define private public
tkchin_webrtc 2017/05/09 17:48:25 oof. Don't do this - not good to redefine keywords
16 #include "webrtc/modules/audio_device/ios/audio_device_ios.h"
14 #include "webrtc/test/gtest.h" 17 #include "webrtc/test/gtest.h"
15 18
16 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h" 19 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h"
17 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession+Private.h" 20 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession+Private.h"
18 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSessionConfiguration.h" 21 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSessionConfiguration.h"
19 22
20 @interface RTCAudioSessionTestDelegate : NSObject <RTCAudioSessionDelegate> 23 @interface RTCAudioSessionTestDelegate : NSObject <RTCAudioSessionDelegate>
21 @end 24 @end
22 25
23 @implementation RTCAudioSessionTestDelegate 26 @implementation RTCAudioSessionTestDelegate
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 [audioSession unlockForConfiguration]; 242 [audioSession unlockForConfiguration];
240 243
241 OCMVerify([mockAudioSession session]); 244 OCMVerify([mockAudioSession session]);
242 OCMVerify([[mockAVAudioSession ignoringNonObjectArgs] setActive:YES withOption s:0 error:&error]); 245 OCMVerify([[mockAVAudioSession ignoringNonObjectArgs] setActive:YES withOption s:0 error:&error]);
243 OCMVerify([[mockAVAudioSession ignoringNonObjectArgs] setActive:NO withOptions :0 error:&error]); 246 OCMVerify([[mockAVAudioSession ignoringNonObjectArgs] setActive:NO withOptions :0 error:&error]);
244 247
245 [mockAVAudioSession stopMocking]; 248 [mockAVAudioSession stopMocking];
246 [mockAudioSession stopMocking]; 249 [mockAudioSession stopMocking];
247 } 250 }
248 251
252 - (void)testInterruptedAudioSession {
tkchin_webrtc 2017/05/09 17:48:25 this belongs in: https://cs.chromium.org/chromium/
253 RTCAudioSession *session = [RTCAudioSession sharedInstance];
254 webrtc::AudioDeviceIOS *audioDevice = new webrtc::AudioDeviceIOS();
255 webrtc::AudioDeviceBuffer *audioBuffer = new webrtc::AudioDeviceBuffer();
256 audioDevice->AttachAudioBuffer(audioBuffer);
257 audioDevice->Init();
258 audioDevice->InitPlayout();
259 [session notifyDidBeginInterruption]; // force interruption
260
261 // Wait for notification to propagate
262 rtc::MessageQueueManager::ProcessAllMessageQueues();
263 EXPECT_TRUE(audioDevice->is_interrupted_);
264
265 audioDevice->playing_ = false; // force it for testing
266 audioDevice->ShutdownPlayOrRecord();
267 audioDevice->audio_is_initialized_ = false; // force it for testing
268
269 [session notifyDidEndInterruptionWithShouldResumeSession:YES];
270 // Wait for notification to propagate
271 rtc::MessageQueueManager::ProcessAllMessageQueues();
272 EXPECT_TRUE(audioDevice->is_interrupted_);
273
274 audioDevice->Init();
275 audioDevice->InitPlayout();
276 EXPECT_FALSE(audioDevice->is_interrupted_);
277 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.
278 delete audioDevice;
279 }
280
249 @end 281 @end
250 282
251 namespace webrtc { 283 namespace webrtc {
252 284
253 class AudioSessionTest : public ::testing::Test { 285 class AudioSessionTest : public ::testing::Test {
254 protected: 286 protected:
255 void TearDown() { 287 void TearDown() {
256 RTCAudioSession *session = [RTCAudioSession sharedInstance]; 288 RTCAudioSession *session = [RTCAudioSession sharedInstance];
257 for (id<RTCAudioSessionDelegate> delegate : session.delegates) { 289 for (id<RTCAudioSessionDelegate> delegate : session.delegates) {
258 [session removeDelegate:delegate]; 290 [session removeDelegate:delegate];
(...skipping 29 matching lines...) Expand all
288 TEST_F(AudioSessionTest, AudioSessionActivation) { 320 TEST_F(AudioSessionTest, AudioSessionActivation) {
289 RTCAudioSessionTest *test = [[RTCAudioSessionTest alloc] init]; 321 RTCAudioSessionTest *test = [[RTCAudioSessionTest alloc] init];
290 [test testAudioSessionActivation]; 322 [test testAudioSessionActivation];
291 } 323 }
292 324
293 TEST_F(AudioSessionTest, ConfigureWebRTCSession) { 325 TEST_F(AudioSessionTest, ConfigureWebRTCSession) {
294 RTCAudioSessionTest *test = [[RTCAudioSessionTest alloc] init]; 326 RTCAudioSessionTest *test = [[RTCAudioSessionTest alloc] init];
295 [test testConfigureWebRTCSession]; 327 [test testConfigureWebRTCSession];
296 } 328 }
297 329
330 TEST_F(AudioSessionTest, testInterruptedAudioSession) {
331 RTCAudioSessionTest *test = [[RTCAudioSessionTest alloc] init];
332 [test testInterruptedAudioSession];
333 }
334
298 } // namespace webrtc 335 } // namespace webrtc
OLDNEW
« 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