You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.7 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2015 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. #import <Foundation/Foundation.h>
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #import <OCMock/OCMock.h>
  15. #ifdef __cplusplus
  16. }
  17. #endif
  18. #import "api/peerconnection/RTCPeerConnectionFactory+Native.h"
  19. #import "api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.h"
  20. #import "api/peerconnection/RTCPeerConnectionFactoryBuilder.h"
  21. #include "api/audio_codecs/builtin_audio_decoder_factory.h"
  22. #include "api/audio_codecs/builtin_audio_encoder_factory.h"
  23. #include "api/transport/media/media_transport_interface.h"
  24. #include "api/video_codecs/video_decoder_factory.h"
  25. #include "api/video_codecs/video_encoder_factory.h"
  26. #include "modules/audio_device/include/audio_device.h"
  27. #include "modules/audio_processing/include/audio_processing.h"
  28. #include "rtc_base/gunit.h"
  29. #include "rtc_base/system/unused.h"
  30. @interface RTCPeerConnectionFactoryBuilderTest : NSObject
  31. - (void)testBuilder;
  32. - (void)testDefaultComponentsBuilder;
  33. @end
  34. @implementation RTCPeerConnectionFactoryBuilderTest
  35. - (void)testBuilder {
  36. id factoryMock = OCMStrictClassMock([RTCPeerConnectionFactory class]);
  37. OCMExpect([factoryMock alloc]).andReturn(factoryMock);
  38. #ifdef HAVE_NO_MEDIA
  39. RTC_UNUSED([[[factoryMock expect] andReturn:factoryMock] initWithNoMedia]);
  40. #else
  41. RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] ignoringNonObjectArgs]
  42. initWithNativeAudioEncoderFactory:nullptr
  43. nativeAudioDecoderFactory:nullptr
  44. nativeVideoEncoderFactory:nullptr
  45. nativeVideoDecoderFactory:nullptr
  46. audioDeviceModule:nullptr
  47. audioProcessingModule:nullptr
  48. mediaTransportFactory:nullptr]);
  49. #endif
  50. RTCPeerConnectionFactoryBuilder* builder = [[RTCPeerConnectionFactoryBuilder alloc] init];
  51. RTCPeerConnectionFactory* peerConnectionFactory = [builder createPeerConnectionFactory];
  52. EXPECT_TRUE(peerConnectionFactory != nil);
  53. OCMVerifyAll(factoryMock);
  54. }
  55. - (void)testDefaultComponentsBuilder {
  56. id factoryMock = OCMStrictClassMock([RTCPeerConnectionFactory class]);
  57. OCMExpect([factoryMock alloc]).andReturn(factoryMock);
  58. #ifdef HAVE_NO_MEDIA
  59. RTC_UNUSED([[[factoryMock expect] andReturn:factoryMock] initWithNoMedia]);
  60. #else
  61. RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] ignoringNonObjectArgs]
  62. initWithNativeAudioEncoderFactory:nullptr
  63. nativeAudioDecoderFactory:nullptr
  64. nativeVideoEncoderFactory:nullptr
  65. nativeVideoDecoderFactory:nullptr
  66. audioDeviceModule:nullptr
  67. audioProcessingModule:nullptr
  68. mediaTransportFactory:nullptr]);
  69. #endif
  70. RTCPeerConnectionFactoryBuilder* builder = [RTCPeerConnectionFactoryBuilder defaultBuilder];
  71. RTCPeerConnectionFactory* peerConnectionFactory = [builder createPeerConnectionFactory];
  72. EXPECT_TRUE(peerConnectionFactory != nil);
  73. OCMVerifyAll(factoryMock);
  74. }
  75. @end
  76. TEST(RTCPeerConnectionFactoryBuilderTest, BuilderTest) {
  77. @autoreleasepool {
  78. RTCPeerConnectionFactoryBuilderTest* test = [[RTCPeerConnectionFactoryBuilderTest alloc] init];
  79. [test testBuilder];
  80. }
  81. }
  82. TEST(RTCPeerConnectionFactoryBuilderTest, DefaultComponentsBuilderTest) {
  83. @autoreleasepool {
  84. RTCPeerConnectionFactoryBuilderTest* test = [[RTCPeerConnectionFactoryBuilderTest alloc] init];
  85. [test testDefaultComponentsBuilder];
  86. }
  87. }