Add a GN target for unit tests, get them working again and added a test.
BUG=webrtc:3417 Review-Url: https://codereview.webrtc.org/2050153003 Cr-Commit-Position: refs/heads/master@{#14959}
This commit is contained in:
1
AUTHORS
1
AUTHORS
@ -1,6 +1,7 @@
|
|||||||
# Names should be added to this file like so:
|
# Names should be added to this file like so:
|
||||||
# Name or Organization <email address>
|
# Name or Organization <email address>
|
||||||
|
|
||||||
|
Adam Fedor <adam.fedor@gmail.com>
|
||||||
Alexander Brauckmann <a.brauckmann@gmail.com>
|
Alexander Brauckmann <a.brauckmann@gmail.com>
|
||||||
Andrew MacDonald <andrew@webrtc.org>
|
Andrew MacDonald <andrew@webrtc.org>
|
||||||
Anil Kumar <an1kumar@gmail.com>
|
Anil Kumar <an1kumar@gmail.com>
|
||||||
|
@ -389,6 +389,33 @@ if (is_ios || (is_mac && target_cpu != "x86")) {
|
|||||||
"icucore",
|
"icucore",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rtc_include_tests) {
|
||||||
|
config("rtc_apprtcmobile_config") {
|
||||||
|
defines = [ "GTEST_RELATIVE_PATH" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
rtc_test("apprtcmobile_tests") {
|
||||||
|
deps = [
|
||||||
|
":apprtc_signaling",
|
||||||
|
"//testing/gtest",
|
||||||
|
"//third_party/ocmock",
|
||||||
|
]
|
||||||
|
|
||||||
|
sources = [
|
||||||
|
"objc/AppRTCMobile/tests/ARDAppClientTest.mm",
|
||||||
|
]
|
||||||
|
|
||||||
|
if (is_ios) {
|
||||||
|
info_plist = "objc/AppRTCMobile/ios/Info.plist"
|
||||||
|
}
|
||||||
|
|
||||||
|
configs += [
|
||||||
|
":rtc_apprtcmobile_config",
|
||||||
|
"//build/config/compiler:enable_arc",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_linux || is_win) {
|
if (is_linux || is_win) {
|
||||||
|
@ -318,7 +318,9 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB.
|
|||||||
_peerConnection = nil;
|
_peerConnection = nil;
|
||||||
self.state = kARDAppClientStateDisconnected;
|
self.state = kARDAppClientStateDisconnected;
|
||||||
#if defined(WEBRTC_IOS)
|
#if defined(WEBRTC_IOS)
|
||||||
RTCStopInternalCapture();
|
if (kARDAppClientEnableTracing) {
|
||||||
|
RTCStopInternalCapture();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <OCMock/OCMock.h>
|
#import <OCMock/OCMock.h>
|
||||||
|
#import <QuartzCore/CoreAnimation.h>
|
||||||
|
|
||||||
#include "webrtc/base/gunit.h"
|
#include "webrtc/base/gunit.h"
|
||||||
#include "webrtc/base/ssladapter.h"
|
#include "webrtc/base/ssladapter.h"
|
||||||
@ -23,6 +24,9 @@
|
|||||||
#import "ARDMessageResponse+Internal.h"
|
#import "ARDMessageResponse+Internal.h"
|
||||||
#import "ARDSDPUtils.h"
|
#import "ARDSDPUtils.h"
|
||||||
|
|
||||||
|
static NSString *kARDAppClientTestsDomain = @"org.webrtc.ARDAppClientTests";
|
||||||
|
static NSInteger kARDAppClientTestsExpectationTimeoutError = 100;
|
||||||
|
|
||||||
// These classes mimic XCTest APIs, to make eventual conversion to XCTest
|
// These classes mimic XCTest APIs, to make eventual conversion to XCTest
|
||||||
// easier. Conversion will happen once XCTest is supported well on build bots.
|
// easier. Conversion will happen once XCTest is supported well on build bots.
|
||||||
@interface ARDTestExpectation : NSObject
|
@interface ARDTestExpectation : NSObject
|
||||||
@ -81,17 +85,20 @@
|
|||||||
|
|
||||||
- (void)waitForExpectationsWithTimeout:(NSTimeInterval)timeout
|
- (void)waitForExpectationsWithTimeout:(NSTimeInterval)timeout
|
||||||
handler:(void (^)(NSError *error))handler {
|
handler:(void (^)(NSError *error))handler {
|
||||||
NSDate *startDate = [NSDate date];
|
CFTimeInterval startTime = CACurrentMediaTime();
|
||||||
|
NSError *error = nil;
|
||||||
while (![self areExpectationsFulfilled]) {
|
while (![self areExpectationsFulfilled]) {
|
||||||
NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:startDate];
|
CFTimeInterval duration = CACurrentMediaTime() - startTime;
|
||||||
if (duration > timeout) {
|
if (duration > timeout) {
|
||||||
NSAssert(NO, @"Expectation timed out.");
|
error = [NSError errorWithDomain:kARDAppClientTestsDomain
|
||||||
|
code:kARDAppClientTestsExpectationTimeoutError
|
||||||
|
userInfo:@{}];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
[[NSRunLoop currentRunLoop]
|
[[NSRunLoop currentRunLoop]
|
||||||
runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
|
runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
|
||||||
}
|
}
|
||||||
handler(nil);
|
handler(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)areExpectationsFulfilled {
|
- (BOOL)areExpectationsFulfilled {
|
||||||
@ -137,7 +144,7 @@
|
|||||||
[[[mockRoomServerClient stub] andDo:^(NSInvocation *invocation) {
|
[[[mockRoomServerClient stub] andDo:^(NSInvocation *invocation) {
|
||||||
__unsafe_unretained void (^completionHandler)(ARDJoinResponse *response,
|
__unsafe_unretained void (^completionHandler)(ARDJoinResponse *response,
|
||||||
NSError *error);
|
NSError *error);
|
||||||
[invocation getArgument:&completionHandler atIndex:3];
|
[invocation getArgument:&completionHandler atIndex:4];
|
||||||
completionHandler(joinResponse, nil);
|
completionHandler(joinResponse, nil);
|
||||||
}] joinRoomWithRoomId:roomId isLoopback:NO completionHandler:[OCMArg any]];
|
}] joinRoomWithRoomId:roomId isLoopback:NO completionHandler:[OCMArg any]];
|
||||||
|
|
||||||
@ -203,7 +210,8 @@
|
|||||||
messages:(NSArray *)messages
|
messages:(NSArray *)messages
|
||||||
messageHandler:
|
messageHandler:
|
||||||
(void (^)(ARDSignalingMessage *message))messageHandler
|
(void (^)(ARDSignalingMessage *message))messageHandler
|
||||||
connectedHandler:(void (^)(void))connectedHandler {
|
connectedHandler:(void (^)(void))connectedHandler
|
||||||
|
localVideoTrackHandler:(void (^)(void))localVideoTrackHandler {
|
||||||
id turnClient = [self mockTURNClient];
|
id turnClient = [self mockTURNClient];
|
||||||
id signalingChannel = [self mockSignalingChannelForRoomId:roomId
|
id signalingChannel = [self mockSignalingChannelForRoomId:roomId
|
||||||
clientId:clientId
|
clientId:clientId
|
||||||
@ -220,6 +228,10 @@
|
|||||||
connectedHandler();
|
connectedHandler();
|
||||||
}] appClient:[OCMArg any]
|
}] appClient:[OCMArg any]
|
||||||
didChangeConnectionState:RTCIceConnectionStateConnected];
|
didChangeConnectionState:RTCIceConnectionStateConnected];
|
||||||
|
[[[delegate stub] andDo:^(NSInvocation *invocation) {
|
||||||
|
localVideoTrackHandler();
|
||||||
|
}] appClient:[OCMArg any]
|
||||||
|
didReceiveLocalVideoTrack:[OCMArg any]];
|
||||||
|
|
||||||
return [[ARDAppClient alloc] initWithRoomServerClient:roomServerClient
|
return [[ARDAppClient alloc] initWithRoomServerClient:roomServerClient
|
||||||
signalingChannel:signalingChannel
|
signalingChannel:signalingChannel
|
||||||
@ -255,8 +267,9 @@
|
|||||||
messageHandler:^(ARDSignalingMessage *message) {
|
messageHandler:^(ARDSignalingMessage *message) {
|
||||||
ARDAppClient *strongAnswerer = weakAnswerer;
|
ARDAppClient *strongAnswerer = weakAnswerer;
|
||||||
[strongAnswerer channel:strongAnswerer.channel didReceiveMessage:message];
|
[strongAnswerer channel:strongAnswerer.channel didReceiveMessage:message];
|
||||||
} connectedHandler:^{
|
} connectedHandler:^{
|
||||||
[callerConnectionExpectation fulfill];
|
[callerConnectionExpectation fulfill];
|
||||||
|
} localVideoTrackHandler:^{
|
||||||
}];
|
}];
|
||||||
// TODO(tkchin): Figure out why DTLS-SRTP constraint causes thread assertion
|
// TODO(tkchin): Figure out why DTLS-SRTP constraint causes thread assertion
|
||||||
// crash in Debug.
|
// crash in Debug.
|
||||||
@ -272,8 +285,9 @@
|
|||||||
messageHandler:^(ARDSignalingMessage *message) {
|
messageHandler:^(ARDSignalingMessage *message) {
|
||||||
ARDAppClient *strongCaller = weakCaller;
|
ARDAppClient *strongCaller = weakCaller;
|
||||||
[strongCaller channel:strongCaller.channel didReceiveMessage:message];
|
[strongCaller channel:strongCaller.channel didReceiveMessage:message];
|
||||||
} connectedHandler:^{
|
} connectedHandler:^{
|
||||||
[answererConnectionExpectation fulfill];
|
[answererConnectionExpectation fulfill];
|
||||||
|
} localVideoTrackHandler:^{
|
||||||
}];
|
}];
|
||||||
// TODO(tkchin): Figure out why DTLS-SRTP constraint causes thread assertion
|
// TODO(tkchin): Figure out why DTLS-SRTP constraint causes thread assertion
|
||||||
// crash in Debug.
|
// crash in Debug.
|
||||||
@ -295,7 +309,44 @@
|
|||||||
shouldUseLevelControl:NO];
|
shouldUseLevelControl:NO];
|
||||||
[self waitForExpectationsWithTimeout:20 handler:^(NSError *error) {
|
[self waitForExpectationsWithTimeout:20 handler:^(NSError *error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"Expectations error: %@", error);
|
EXPECT_TRUE(0);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test to see that we get a local video connection
|
||||||
|
// Note this will currently pass even when no camera is connected as a local
|
||||||
|
// video track is created regardless (Perhaps there should be a test for that...)
|
||||||
|
- (void)testSessionShouldGetLocalVideoTrackCallback {
|
||||||
|
ARDAppClient *caller = nil;
|
||||||
|
NSString *roomId = @"testRoom";
|
||||||
|
NSString *callerId = @"testCallerId";
|
||||||
|
|
||||||
|
ARDTestExpectation *localVideoTrackExpectation =
|
||||||
|
[self expectationWithDescription:@"Caller got local video."];
|
||||||
|
|
||||||
|
caller = [self createAppClientForRoomId:roomId
|
||||||
|
clientId:callerId
|
||||||
|
isInitiator:YES
|
||||||
|
messages:[NSArray array]
|
||||||
|
messageHandler:^(ARDSignalingMessage *message) {
|
||||||
|
} connectedHandler:^{
|
||||||
|
} localVideoTrackHandler:^{
|
||||||
|
[localVideoTrackExpectation fulfill];
|
||||||
|
}];
|
||||||
|
caller.defaultPeerConnectionConstraints =
|
||||||
|
[[RTCMediaConstraints alloc] initWithMandatoryConstraints:nil
|
||||||
|
optionalConstraints:nil];
|
||||||
|
|
||||||
|
// Kick off connection.
|
||||||
|
[caller connectToRoomWithId:roomId
|
||||||
|
isLoopback:NO
|
||||||
|
isAudioOnly:NO
|
||||||
|
shouldMakeAecDump:NO
|
||||||
|
shouldUseLevelControl:NO];
|
||||||
|
[self waitForExpectationsWithTimeout:20 handler:^(NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
EXPECT_TRUE(0);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@ -318,7 +369,7 @@
|
|||||||
RTCSessionDescription *h264Desc =
|
RTCSessionDescription *h264Desc =
|
||||||
[ARDSDPUtils descriptionForDescription:desc
|
[ARDSDPUtils descriptionForDescription:desc
|
||||||
preferredVideoCodec:@"H264"];
|
preferredVideoCodec:@"H264"];
|
||||||
EXPECT_TRUE([h264Desc.description isEqualToString:expectedSdp]);
|
EXPECT_TRUE([h264Desc.description rangeOfString:expectedSdp].location != NSNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@ -340,6 +391,16 @@ TEST_F(SignalingTest, SessionTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !TARGET_IPHONE_SIMULATOR
|
||||||
|
// Expected fail on iOS Simulator due to no camera support
|
||||||
|
TEST_F(SignalingTest, SessionLocalVideoCallbackTest) {
|
||||||
|
@autoreleasepool {
|
||||||
|
ARDAppClientTest *test = [[ARDAppClientTest alloc] init];
|
||||||
|
[test testSessionShouldGetLocalVideoTrackCallback];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST_F(SignalingTest, SDPTest) {
|
TEST_F(SignalingTest, SDPTest) {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
ARDSDPUtilsTest *test = [[ARDSDPUtilsTest alloc] init];
|
ARDSDPUtilsTest *test = [[ARDSDPUtilsTest alloc] init];
|
||||||
@ -347,4 +408,7 @@ TEST_F(SignalingTest, SDPTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user