Support compiling with the lastest iOS SDK.

Bug: None
Change-Id: I2bc4b4f3eba9c5f6b3a94fce076dc575c5be057d
Reviewed-on: https://webrtc-review.googlesource.com/90720
Reviewed-by: Peter Hanspers <peterhanspers@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24163}
This commit is contained in:
Kári Tristan Helgason
2018-07-27 12:34:54 +02:00
committed by Commit Bot
parent 55bf92adf4
commit 9014324bb1
5 changed files with 14 additions and 42 deletions

View File

@ -457,7 +457,7 @@ if (rtc_include_tests) {
}
if (is_ios || is_mac) {
deps += [ "sdk:sdk_unittests_objc" ]
deps += [ "sdk:rtc_unittests_objc" ]
}
}

View File

@ -862,7 +862,7 @@ if (is_ios || is_mac) {
}
# TODO(denicija): once all tests are migrated to xctest remove this source set.
rtc_source_set("sdk_unittests_objc") {
rtc_source_set("rtc_unittests_objc") {
testonly = true
sources = [

View File

@ -92,6 +92,10 @@
#endif
}
+ (MTKView *)createMetalView:(CGRect)frame {
return [[MTKViewClass alloc] initWithFrame:frame];
}
+ (RTCMTLNV12Renderer *)createNV12Renderer {
return [[RTCMTLNV12RendererClass alloc] init];
}
@ -107,7 +111,7 @@
- (void)configure {
NSAssert([RTCMTLVideoView isMetalAvailable], @"Metal not availiable on this device");
self.metalView = [[MTKViewClass alloc] initWithFrame:self.bounds];
self.metalView = [RTCMTLVideoView createMetalView:self.bounds];
self.metalView.delegate = self;
self.metalView.contentMode = UIViewContentModeScaleAspectFill;
[self addSubview:self.metalView];
@ -194,12 +198,9 @@
- (RTCVideoRotation)frameRotation {
if (self.rotationOverride) {
RTCVideoRotation rotation;
#if defined(__IPHONE_11_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0)
if (@available(iOS 11, *)) {
[self.rotationOverride getValue:&rotation size:sizeof(rotation)];
} else
#endif
{
} else {
[self.rotationOverride getValue:&rotation];
}
return rotation;

View File

@ -194,13 +194,7 @@ CMSampleBufferRef createTestSampleBufferRef() {
- (void)testDelegateCallbackWithValidBufferAndOrientationUpdate {
#if TARGET_OS_IPHONE
// given
UIDevice *currentDeviceMock = OCMClassMock([UIDevice class]);
// UpsideDown -> RTCVideoRotation_270.
OCMStub(currentDeviceMock.orientation).andReturn(UIDeviceOrientationPortraitUpsideDown);
id classMock = OCMClassMock([UIDevice class]);
OCMStub([classMock currentDevice]).andReturn(currentDeviceMock);
[UIDevice.currentDevice setValue:@(UIDeviceOrientationPortraitUpsideDown) forKey:@"orientation"];
CMSampleBufferRef sampleBuffer = createTestSampleBufferRef();
// then
@ -222,11 +216,6 @@ CMSampleBufferRef createTestSampleBufferRef() {
fromConnection:self.captureConnectionMock];
[self.delegateMock verify];
[(id)currentDeviceMock stopMocking];
currentDeviceMock = nil;
[classMock stopMocking];
classMock = nil;
CFRelease(sampleBuffer);
#endif
}
@ -246,11 +235,7 @@ CMSampleBufferRef createTestSampleBufferRef() {
OCMStub(inputPortMock.device).andReturn(captureDeviceMock);
OCMStub(captureDeviceMock.position).andReturn(camera);
// UpsideDown -> RTCVideoRotation_0.
UIDevice *currentDeviceMock = OCMClassMock([UIDevice class]);
OCMStub(currentDeviceMock.orientation).andReturn(deviceOrientation);
id classMock = OCMClassMock([UIDevice class]);
OCMStub([classMock currentDevice]).andReturn(currentDeviceMock);
[UIDevice.currentDevice setValue:@(deviceOrientation) forKey:@"orientation"];
CMSampleBufferRef sampleBuffer = createTestSampleBufferRef();
@ -284,10 +269,6 @@ CMSampleBufferRef createTestSampleBufferRef() {
[self.delegateMock verify];
[(id)currentDeviceMock stopMocking];
currentDeviceMock = nil;
[classMock stopMocking];
classMock = nil;
CFRelease(sampleBuffer);
#endif
}
@ -312,11 +293,7 @@ CMSampleBufferRef createTestSampleBufferRef() {
OCMStub(inputPortMock.device).andReturn(captureDeviceMock);
OCMStub(captureDeviceMock.position).andReturn(AVCaptureDevicePositionFront);
// UpsideDown -> RTCVideoRotation_0.
UIDevice *currentDeviceMock = OCMClassMock([UIDevice class]);
OCMStub(currentDeviceMock.orientation).andReturn(UIDeviceOrientationLandscapeLeft);
id classMock = OCMClassMock([UIDevice class]);
OCMStub([classMock currentDevice]).andReturn(currentDeviceMock);
[UIDevice.currentDevice setValue:@(UIDeviceOrientationLandscapeLeft) forKey:@"orientation"];
CMSampleBufferRef sampleBuffer = createTestSampleBufferRef();
@ -341,11 +318,6 @@ CMSampleBufferRef createTestSampleBufferRef() {
fromConnection:self.captureConnectionMock];
[self.delegateMock verify];
[(id)currentDeviceMock stopMocking];
currentDeviceMock = nil;
[classMock stopMocking];
classMock = nil;
CFRelease(sampleBuffer);
#endif
}

View File

@ -74,10 +74,9 @@
return frameMock;
}
- (id)rendererMockWithSuccessfulSetup:(BOOL)sucess {
id rendererMock = OCMProtocolMock(@protocol(RTCMTLRenderer));
OCMStub([rendererMock addRenderingDestination:[OCMArg any]]).andReturn(sucess);
- (id)rendererMockWithSuccessfulSetup:(BOOL)success {
id rendererMock = OCMClassMock([RTCMTLRenderer class]);
OCMStub([rendererMock addRenderingDestination:[OCMArg any]]).andReturn(success);
return rendererMock;
}