Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'feature/CallKit-integration-3280' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Harold committed Nov 17, 2016
2 parents 62a8fe7 + 1c74d89 commit 8574bb7
Show file tree
Hide file tree
Showing 44 changed files with 2,316 additions and 693 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Example/Pods/
!Podfile
!Podfile.lock

# XCODE
*.xcscmblueprint

#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
Expand Down
38 changes: 38 additions & 0 deletions Example/IntentsExtension/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>IntentsExtension</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>IntentsSupported</key>
<array>
<string>INStartAudioCallIntent</string>
</array>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.intents-service</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).IntentHandler</string>
</dict>
</dict>
</plist>
32 changes: 32 additions & 0 deletions Example/IntentsExtension/IntentHandler.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright (C) 2016 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information

Abstract:
Intents handler principal class

Copied from Speakerbox example app.
*/

import Intents

class IntentHandler: INExtension, INStartAudioCallIntentHandling {

func handle(startAudioCall intent: INStartAudioCallIntent, completion: @escaping (INStartAudioCallIntentResponse) -> Void) {
let response: INStartAudioCallIntentResponse
defer {
completion(response)
}

// Ensure there is a person handle.
guard intent.contacts?.first?.personHandle != nil else {
response = INStartAudioCallIntentResponse(code: .failure, userActivity: nil)
return
}

let userActivity = NSUserActivity(activityType: String(describing: INStartAudioCallIntent.self))

response = INStartAudioCallIntentResponse(code: .continueInApp, userActivity: userActivity)
}

}
22 changes: 11 additions & 11 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
PODS:
- CocoaLumberjack (2.3.0):
- CocoaLumberjack/Default (= 2.3.0)
- CocoaLumberjack/Extensions (= 2.3.0)
- CocoaLumberjack/Core (2.3.0)
- CocoaLumberjack/Default (2.3.0):
- CocoaLumberjack (3.0.0):
- CocoaLumberjack/Default (= 3.0.0)
- CocoaLumberjack/Extensions (= 3.0.0)
- CocoaLumberjack/Core (3.0.0)
- CocoaLumberjack/Default (3.0.0):
- CocoaLumberjack/Core
- CocoaLumberjack/Extensions (2.3.0):
- CocoaLumberjack/Extensions (3.0.0):
- CocoaLumberjack/Default
- OCMock (3.3.1)
- Reachability (3.2)
- Vialer-pjsip-iOS (1.0)
- VialerSIPLib (1.0.5):
- CocoaLumberjack (~> 2.2)
- VialerSIPLib (1.0.6):
- CocoaLumberjack
- Reachability
- Vialer-pjsip-iOS

Expand All @@ -26,12 +26,12 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
CocoaLumberjack: 97fab7ee5f507fe54445cca7ea80f926729cfd15
CocoaLumberjack: c823149bccc5519a9447aeb433be7b1212a7d6a5
OCMock: f3f61e6eaa16038c30caa5798c5e49d3307b6f22
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
Vialer-pjsip-iOS: 7313b19c4c2fa228a419f697a95aff1c17e649f3
VialerSIPLib: 35241a8affe9a31d139297cb7de32dceea40add9
VialerSIPLib: a544d577e75e1f3f08c85c55d667749bae1a1e57

PODFILE CHECKSUM: 0f7b04fb045caf39ed7c2486524959b2d2be90e8

COCOAPODS: 1.0.1
COCOAPODS: 1.1.1
12 changes: 11 additions & 1 deletion Example/Tests/VSLAccountTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@
#import <OCMock/OCMock.h>
#import <VialerPJSIP/pjsua.h>
#import <VialerSIPLib/VSLAccount.h>
#import <VialerSIPLib/VSLCallManager.h>
#import <VialerSIPLib/VSLEndpoint.h>
#import <XCTest/XCTest.h>

@interface VSLAccountTests : XCTestCase
@property (strong, nonatomic) id callManagerMock;
@property (strong, nonatomic) VSLAccount *account;
@end

@implementation VSLAccountTests

- (void)setUp {
[super setUp];
self.account = [[VSLAccount alloc] init];
self.callManagerMock = OCMStrictClassMock([VSLCallManager class]);
self.account = [[VSLAccount alloc] initWithCallManager:self.callManagerMock];
}

- (void)tearDown {
self.account = nil;
[self.callManagerMock stopMocking];
self.callManagerMock = nil;
[super tearDown];
}

- (void)testAccountHasDefaultInvalidAccountId {
Expand Down
67 changes: 67 additions & 0 deletions Example/Tests/VSLCallManagerTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// VSLCallManagerTests.m
// Copyright © 2016 Devhouse Spindle. All rights reserved.
//

#import <OCMock/OCMock.h>
#import <XCTest/XCTest.h>
#import <VialerSIPLib/VSLAccount.h>
#import <VialerSIPLib/VSLCall.h>
#import <VialerSIPLib/VSLCallManager.h>

@interface VSLCallManagerTests : XCTestCase
@property (strong, nonatomic) id accountMock;
@property (strong, nonatomic) VSLCallManager *callManagerUnderTest;
@end

@implementation VSLCallManagerTests

- (void)setUp {
[super setUp];
self.accountMock = OCMStrictClassMock([VSLAccount class]);
self.callManagerUnderTest = [[VSLCallManager alloc] init];
}

- (void)tearDown {
[self.accountMock stopMocking];
self.accountMock = nil;
[super tearDown];
}

- (void)testCallsForAccount {
VSLCall *mockCall1 = [[VSLCall alloc] initInboundCallWithCallId:1 account:self.accountMock];
VSLCall *mockCall2 = [[VSLCall alloc] initOutboundCallWithNumberToCall:@"123" account:self.accountMock];

[self.callManagerUnderTest addCall:mockCall1];
[self.callManagerUnderTest addCall:mockCall2];

NSArray *callsForAccount = [self.callManagerUnderTest callsForAccount:self.accountMock];

XCTAssertNotNil(callsForAccount, @"Calls array for account should not have been nil");
XCTAssert(callsForAccount.count == 2, @"Incorrect number of calls for account returned. Calls count:%@", [[NSNumber numberWithUnsignedInteger:callsForAccount.count] stringValue]);
XCTAssert([callsForAccount containsObject:mockCall1], @"mockCall1 should have been in calls array for account");
XCTAssert([callsForAccount containsObject:mockCall2], @"mockCall2 should have been in calls array for account");

[self.accountMock verify];
}

- (void)testCallForDifferentAccountShouldNotBeReturned {
id differentAccountMock = OCMStrictClassMock([VSLAccount class]);
VSLCall *mockCall1 = [[VSLCall alloc] initInboundCallWithCallId:1 account:differentAccountMock];
VSLCall *mockCall2 = [[VSLCall alloc] initOutboundCallWithNumberToCall:@"123" account:differentAccountMock];

[self.callManagerUnderTest addCall:mockCall1];
[self.callManagerUnderTest addCall:mockCall2];

NSArray *callsForAccount = [self.callManagerUnderTest callsForAccount:self.accountMock];

XCTAssertNil(callsForAccount, @"Calls for account array should have been nil");
XCTAssert(callsForAccount.count == 0, @"Incorrect number of calls for account returned. Calls count:%@", [[NSNumber numberWithUnsignedInteger:callsForAccount.count] stringValue]);
XCTAssert(![callsForAccount containsObject:mockCall1], @"mockCall1 should have been in calls array for account");
XCTAssert(![callsForAccount containsObject:mockCall2], @"mockCall2 should have been in calls array for account");

[self.accountMock verify];
[differentAccountMock verify];
}

@end
22 changes: 17 additions & 5 deletions Example/Tests/VSLCallTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,34 @@

#import <OCMock/OCMock.h>
#import <XCTest/XCTest.h>
#import <VialerSIPLib/VSLAccount.h>
#import <VialerSIPLib/VSLCall.h>

@interface VSLCall()
- (NSDictionary * _Nonnull)getCallerInfoFromRemoteUri:(NSString * _Nonnull)string;
@end

@interface VSLCallTests : XCTestCase

@property (strong, nonatomic) id accountMock;
@end

@implementation VSLCallTests

- (void)setUp {
[super setUp];
self.accountMock = OCMStrictClassMock([VSLAccount class]);
}

- (void)tearDown {
[self.accountMock stopMocking];
self.accountMock = nil;
[super tearDown];
}

- (void)testCallerNameCallerNumberOne {
NSString *inputString = @"\"test\" <sip:[email protected]>";

VSLCall *call = [[VSLCall alloc] init];
VSLCall *call = [[VSLCall alloc] initInboundCallWithCallId:0 account:self.accountMock];
NSDictionary *dictionary = [call getCallerInfoFromRemoteUri:inputString];

XCTAssert([dictionary[@"caller_name"] isEqualToString:@"test"], @"The caller_name needs to be test");
Expand All @@ -30,7 +42,7 @@ - (void)testCallerNameCallerNumberOne {
- (void)testCallerNameCallerNumberTwo {
NSString *inputString = @"sip:[email protected] (test)";

VSLCall *call = [[VSLCall alloc] init];
VSLCall *call = [[VSLCall alloc] initInboundCallWithCallId:0 account:self.accountMock];
NSDictionary *dictionary = [call getCallerInfoFromRemoteUri:inputString];

XCTAssert([dictionary[@"caller_name"] isEqualToString:@"test"], @"The caller_name needs to be test");
Expand All @@ -40,7 +52,7 @@ - (void)testCallerNameCallerNumberTwo {
- (void)testCallerNameNoDisplayNameInRemoteURI {
NSString *inputString = @"<sip:[email protected]>";

VSLCall *call = [[VSLCall alloc] init];
VSLCall *call = [[VSLCall alloc] initInboundCallWithCallId:0 account:self.accountMock];
NSDictionary *dictionary = [call getCallerInfoFromRemoteUri:inputString];

XCTAssert([dictionary[@"caller_name"] isEqualToString:@""], @"The caller_name needs to be empty");
Expand All @@ -50,7 +62,7 @@ - (void)testCallerNameNoDisplayNameInRemoteURI {
- (void)testCallerNameNoDisplayNameInRemoteURITwo {
NSString *inputString = @"sip:[email protected]";

VSLCall *call = [[VSLCall alloc] init];
VSLCall *call =[[VSLCall alloc] initInboundCallWithCallId:0 account:self.accountMock];
NSDictionary *dictionary = [call getCallerInfoFromRemoteUri:inputString];

XCTAssert([dictionary[@"caller_name"] isEqualToString:@""], @"The caller_name needs to be empty");
Expand Down
14 changes: 10 additions & 4 deletions Example/Tests/VSLEndpointTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
#import <XCTest/XCTest.h>
#import <VialerSIPLib/VSLAccount.h>
#import <VialerSIPLib/VSLAccountConfiguration.h>
#import <VialerSIPLib/VSLCallManager.h>
#import <VialerSIPLib/VSLEndpoint.h>

@interface VSLEndpointTests : XCTestCase
@property (strong, nonatomic) id callManagerMock;
@property (strong, nonatomic) VSLEndpoint *endpoint;
@end

Expand All @@ -18,10 +20,14 @@ @implementation VSLEndpointTests
- (void)setUp {
[super setUp];
self.endpoint = [[VSLEndpoint alloc] init];
self.callManagerMock = OCMStrictClassMock([VSLCallManager class]);
}

- (void)tearDown {
self.endpoint = nil;
[self.callManagerMock stopMocking];
self.callManagerMock = nil;
[super tearDown];
}

- (void)testEndpointHasOnDefaultNoAccounts {
Expand All @@ -30,22 +36,22 @@ - (void)testEndpointHasOnDefaultNoAccounts {
}

- (void)testEndpointWithAddedAccountShouldHaveTheAccount {
VSLAccount *account = [[VSLAccount alloc] init];
VSLAccount *account = [[VSLAccount alloc] initWithCallManager:self.callManagerMock];
[self.endpoint addAccount:account];

XCTAssertTrue([self.endpoint.accounts containsObject:account], @"The account should have been added to the array");
}

- (void)testCanRemoveAddedAccount {
VSLAccount *account = [[VSLAccount alloc] init];
VSLAccount *account = [[VSLAccount alloc] initWithCallManager:self.callManagerMock];
[self.endpoint addAccount:account];
[self.endpoint removeAccount:account];

XCTAssertFalse([self.endpoint.accounts containsObject:account], @"The account should have been removed from the array");
}

- (void)testNoAccountFoundGetAccountWithSiperUsernameReturnsNil {
[self.endpoint addAccount:[[VSLAccount alloc] init]];
[self.endpoint addAccount:[[VSLAccount alloc] initWithCallManager:self.callManagerMock]];

VSLAccount *account = [self.endpoint getAccountWithSipAccount:@"42"];
XCTAssertNil(account, @"There should be no account found when the sip username is not found");
Expand All @@ -58,7 +64,7 @@ - (void)testAccountFoundFromGetAccountWithSipAccount {
config.sipAccount = @"42";
config.sipDomain = @"sip.test.com";

VSLAccount *testAccount = [[VSLAccount alloc] init];
VSLAccount *testAccount = [[VSLAccount alloc] initWithCallManager:self.callManagerMock];
[testAccount configureWithAccountConfiguration:config error:nil];
[self.endpoint addAccount:testAccount];

Expand Down
Loading

0 comments on commit 8574bb7

Please sign in to comment.