mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Fork test/ios/google_test_runner.mm from Chromium's //base
WebRTC should not depend on Chromium's //base. Bug: webrtc:13662 Change-Id: I7ce7036c96b26a79de46a519ed24dd660a298433 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260925 Commit-Queue: Björn Terelius <terelius@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Andrey Logvin <landrey@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36754}
This commit is contained in:
parent
b0eb25f01c
commit
49850c328c
4 changed files with 58 additions and 8 deletions
|
@ -298,7 +298,10 @@ rtc_library("perf_test") {
|
|||
if (is_ios) {
|
||||
rtc_library("test_support_objc") {
|
||||
testonly = true
|
||||
visibility = [ ":test_support" ]
|
||||
visibility = [
|
||||
":google_test_runner_objc",
|
||||
":test_support",
|
||||
]
|
||||
sources = [
|
||||
"ios/coverage_util_ios.h",
|
||||
"ios/coverage_util_ios.mm",
|
||||
|
@ -314,6 +317,15 @@ if (is_ios) {
|
|||
configs += [ ":test_support_objc_config" ]
|
||||
}
|
||||
|
||||
rtc_library("google_test_runner_objc") {
|
||||
testonly = true
|
||||
visibility = [ "*" ]
|
||||
sources = [ "ios/google_test_runner.mm" ]
|
||||
deps = [ ":test_support_objc" ]
|
||||
configs += [ "//build/config/ios:xctest_config" ]
|
||||
frameworks = [ "UIKit.framework" ]
|
||||
}
|
||||
|
||||
config("test_support_objc_config") {
|
||||
defines = []
|
||||
|
||||
|
@ -976,9 +988,7 @@ if (is_mac) {
|
|||
"mac/video_renderer_mac.h",
|
||||
"mac/video_renderer_mac.mm",
|
||||
]
|
||||
deps = [
|
||||
":test_renderer_generic",
|
||||
]
|
||||
deps = [ ":test_renderer_generic" ]
|
||||
frameworks = [
|
||||
"Cocoa.framework",
|
||||
"OpenGL.framework",
|
||||
|
|
40
test/ios/google_test_runner.mm
Normal file
40
test/ios/google_test_runner.mm
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
// Copied from Chromium base/test/ios/google_test_runner.mm to avoid
|
||||
// the //base dependency. The protocol is required to run iOS Unittest.
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "test/ios/google_test_runner_delegate.h"
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
@interface GoogleTestRunner : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation GoogleTestRunner
|
||||
|
||||
- (void)testRunGoogleTests {
|
||||
self.continueAfterFailure = false;
|
||||
|
||||
id appDelegate = UIApplication.sharedApplication.delegate;
|
||||
XCTAssertTrue([appDelegate conformsToProtocol:@protocol(GoogleTestRunnerDelegate)]);
|
||||
|
||||
id<GoogleTestRunnerDelegate> runnerDelegate =
|
||||
static_cast<id<GoogleTestRunnerDelegate>>(appDelegate);
|
||||
XCTAssertTrue(runnerDelegate.supportsRunningGoogleTests);
|
||||
XCTAssertTrue([runnerDelegate runGoogleTests] == 0);
|
||||
}
|
||||
|
||||
@end
|
|
@ -12,8 +12,8 @@
|
|||
#define TEST_IOS_GOOGLE_TEST_RUNNER_DELEGATE_H_
|
||||
|
||||
// Copied from Chromium base/test/ios/google_test_runner_delegate.h
|
||||
// The WebRTC test cannot depend on //base, but this protocol is required
|
||||
// to run iOS Unittest, so it is a workaround for the dependency.
|
||||
// to avoid the //base dependency. This protocol is required
|
||||
// to run iOS Unittest.
|
||||
@protocol GoogleTestRunnerDelegate
|
||||
|
||||
// Returns YES if this delegate supports running GoogleTests via a call to
|
||||
|
|
|
@ -498,10 +498,10 @@ template("rtc_test") {
|
|||
]
|
||||
}
|
||||
|
||||
# Build //base/test:google_test_runner when the test is not a real XCTest.
|
||||
# Build //test:google_test_runner_objc when the test is not a real XCTest.
|
||||
if (is_ios && rtc_include_tests) {
|
||||
if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
|
||||
xctest_module_target = "//base/test:google_test_runner"
|
||||
xctest_module_target = "//test:google_test_runner_objc"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue