diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index ffc1e8da03..14011325e7 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -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). diff --git a/sdk/objc/Framework/UnitTests/RTCMTLVideoViewTests.mm b/sdk/objc/Framework/UnitTests/RTCMTLVideoView_xctest.mm similarity index 82% rename from sdk/objc/Framework/UnitTests/RTCMTLVideoViewTests.mm rename to sdk/objc/Framework/UnitTests/RTCMTLVideoView_xctest.mm index ad4903a90f..602c699dba 100644 --- a/sdk/objc/Framework/UnitTests/RTCMTLVideoViewTests.mm +++ b/sdk/objc/Framework/UnitTests/RTCMTLVideoView_xctest.mm @@ -8,26 +8,27 @@ * be found in the AUTHORS file in the root of the source tree. */ +#import + #import #import -#include "rtc_base/gunit.h" - -#include #include #include +#include "Metal/RTCMTLNV12Renderer.h" + // Extension of RTCMTLVideoView for testing purposes. @interface RTCMTLVideoView (Testing) + (BOOL)isMetalAvailable; -+ (UIView*)createMetalView:(CGRect)frame; ++ (UIView *)createMetalView:(CGRect)frame; + (id)createNV12Renderer; + (id)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]; -} diff --git a/sdk/objc/Framework/UnitTests/main.m b/sdk/objc/Framework/UnitTests/main.m new file mode 100644 index 0000000000..217fb4f479 --- /dev/null +++ b/sdk/objc/Framework/UnitTests/main.m @@ -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 +#import + +int main(int argc, char* argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, nil); + } +} diff --git a/tools_webrtc/ios/tests/common_tests.json b/tools_webrtc/ios/tests/common_tests.json index a3238b53e4..c0ad895288 100644 --- a/tools_webrtc/ios/tests/common_tests.json +++ b/tools_webrtc/ios/tests/common_tests.json @@ -4,6 +4,10 @@ "app": "apprtcmobile_tests", "xctest": true }, + { + "app": "sdk_unittests", + "xctest": true + }, { "app": "audio_decoder_unittests" },