Add xctest target to migrate sdk/objc/Framework to it.

This CL adds all the scaffolding needed to support xctest target
in sdk/objc/Framework and adds the target to the bot configuration.

The benefits of this are two-fold.
1. We'll separate framework unittests from their current target,
`rtc_unittests`, that has many many other tests.
This way framework unit tests will have nice, compact, selfcontained target.
2. We'll harvest the power of XCTest (native testing framework)
that should hopefully make adding and writing objc tests easier.

This CL migrates only one test to prove the setup works.
More tests will be migrated in follow up cls.

Bug: webrtc:8382
Change-Id: I0b5b9596c2a6d91683d13632323441de1aa461e0
Reviewed-on: https://webrtc-review.googlesource.com/8501
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Henrik Kjellander <kjellander@webrtc.org>
Reviewed-by: Daniela Jovanoska Petrenko <denicija@webrtc.org>
Commit-Queue: Daniela Jovanoska Petrenko <denicija@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20289}
This commit is contained in:
Daniela 2017-10-12 13:46:00 +02:00 committed by Commit Bot
parent 052c78d93f
commit ae012cf8b8
4 changed files with 86 additions and 49 deletions

View File

@ -512,6 +512,60 @@ if (is_ios || is_mac) {
}
if (rtc_include_tests) {
# TODO(denicija):remove second part of this check.
if (is_ios && (current_cpu == "arm64" || use_ios_simulator)) {
rtc_source_set("sdk_unittests_sources") {
testonly = true
include_dirs = [
"objc/Framework/Headers",
"objc/Framework/Classes",
]
sources = [
# TODO(denicija): Once more sources are included,
# move the second part of the check on line 516 here
# when adding this file to the sources
"objc/Framework/UnitTests/RTCMTLVideoView_xctest.mm",
]
if (use_ios_simulator) {
# Only include this file on simulator, as it's already
# included in device builds.
sources += [ "objc/Framework/Classes/Metal/RTCMTLVideoView.m" ]
libs = [ "CoreVideo.framework" ]
}
deps = [
":common_objc",
":peerconnection_objc",
":peerconnectionfactory_objc",
":videotoolbox_objc",
":videotracksource_objc",
"..//system_wrappers:system_wrappers_default",
"../media:rtc_media_base",
"../modules:module_api",
"../rtc_base:rtc_base",
"../rtc_base:rtc_base_tests_utils",
"../system_wrappers:system_wrappers_default",
]
public_deps = [
"//build/config/ios:xctest",
"//third_party/ocmock",
]
}
rtc_ios_xctest_test("sdk_unittests") {
info_plist = "//test/ios/Info.plist"
sources = [
"objc/Framework/UnitTests/main.m",
]
_bundle_id_suffix = ios_generic_test_bundle_id_suffix
extra_substitutions = [ "GTEST_BUNDLE_ID_SUFFIX=$_bundle_id_suffix" ]
deps = [
":sdk_unittests_sources",
]
ldflags = [ "-all_load" ]
}
}
# TODO(denicija): once all tests are migrated to xctest remove this source set.
rtc_source_set("sdk_unittests_objc") {
testonly = true
@ -567,18 +621,8 @@ if (is_ios || is_mac) {
if (is_ios) {
sources += [ "objc/Framework/UnitTests/RTCAudioSessionTest.mm" ]
# RTCMTLVideoView not supported on 32-bit arm
if (current_cpu != "arm") {
sources += [ "objc/Framework/UnitTests/RTCMTLVideoViewTests.mm" ]
if (current_cpu != "arm64") {
# Only include this file on simulator, as it's already
# included in device builds.
sources += [ "objc/Framework/Classes/Metal/RTCMTLVideoView.m" ]
libs = [ "CoreVideo.framework" ]
}
}
}
if (!build_with_chromium && is_clang) {
# Suppress warnings from the Chromium Clang plugin
# (bugs.webrtc.org/163).

View File

@ -8,26 +8,27 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#import <XCTest/XCTest.h>
#import <Foundation/Foundation.h>
#import <OCMock/OCMock.h>
#include "rtc_base/gunit.h"
#include <Metal/RTCMTLNV12Renderer.h>
#include <WebRTC/RTCMTLVideoView.h>
#include <WebRTC/RTCVideoFrameBuffer.h>
#include "Metal/RTCMTLNV12Renderer.h"
// Extension of RTCMTLVideoView for testing purposes.
@interface RTCMTLVideoView (Testing)
+ (BOOL)isMetalAvailable;
+ (UIView*)createMetalView:(CGRect)frame;
+ (UIView *)createMetalView:(CGRect)frame;
+ (id<RTCMTLRenderer>)createNV12Renderer;
+ (id<RTCMTLRenderer>)createI420Renderer;
- (void)drawInMTKView:(id)view;
@end
@interface RTCMTLVideoViewTests : NSObject
@interface RTCMTLVideoViewTests : XCTestCase
@property(nonatomic, strong) id classMock;
@property(nonatomic, strong) id rendererNV12Mock;
@property(nonatomic, strong) id rendererI420Mock;
@ -41,7 +42,7 @@
@synthesize rendererI420Mock = _rendererI420Mock;
@synthesize frameMock = _frameMock;
- (void)setup {
- (void)setUp {
self.classMock = OCMClassMock([RTCMTLVideoView class]);
[self startMockingNilView];
}
@ -101,7 +102,7 @@
asserts = YES;
}
EXPECT_TRUE(asserts);
XCTAssertTrue(asserts);
}
- (void)testRTCVideoRenderNilFrameCallback {
@ -165,35 +166,5 @@
[self.rendererNV12Mock verify];
[self.classMock verify];
}
@end
TEST(RTCMTLVideoViewTests, InitAssertsIfMetalUnavailabe) {
RTCMTLVideoViewTests *test = [[RTCMTLVideoViewTests alloc] init];
[test setup];
[test testInitAssertsIfMetalUnavailabe];
[test tearDown];
}
TEST(RTCMTLVideoViewTests, RTCVideoRenderNilFrameCallback) {
RTCMTLVideoViewTests *test = [[RTCMTLVideoViewTests alloc] init];
[test setup];
[test testRTCVideoRenderNilFrameCallback];
[test tearDown];
}
TEST(RTCMTLVideoViewTests, RTCVideoRenderFrameCallbackI420) {
RTCMTLVideoViewTests *test = [[RTCMTLVideoViewTests alloc] init];
[test setup];
[test testRTCVideoRenderFrameCallbackI420];
[test tearDown];
}
TEST(RTCMTLVideoViewTests, RTCVideoRenderFrameCallbackNV12) {
RTCMTLVideoViewTests *test = [[RTCMTLVideoViewTests alloc] init];
[test setup];
[test testRTCVideoRenderFrameCallbackNV12];
[test tearDown];
}

View File

@ -0,0 +1,18 @@
/*
* Copyright 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
int main(int argc, char* argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, nil);
}
}

View File

@ -4,6 +4,10 @@
"app": "apprtcmobile_tests",
"xctest": true
},
{
"app": "sdk_unittests",
"xctest": true
},
{
"app": "audio_decoder_unittests"
},