Merge branch 'charlesmchen/fix-ssk-tests-k2'

This commit is contained in:
Matthew Chen 2018-09-14 14:18:51 -04:00
commit 68714b296c
27 changed files with 233 additions and 233 deletions

2
Pods

@ -1 +1 @@
Subproject commit 327edd6db716ef97af817b170155ed4b4487d891
Subproject commit 6f5013b6f65fa1d988c9a2a027ea2b09f995ab95

View file

@ -28,7 +28,7 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1115976DB2D993FB7AAB33CEBB52F472"
BlueprintIdentifier = "237277EA071A0C42090E0E10F34EFC45"
BuildableName = "SignalServiceKit.framework"
BlueprintName = "SignalServiceKit"
ReferencedContainer = "container:Pods/Pods.xcodeproj">
@ -56,7 +56,7 @@
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B50508FED0E49769CFCF3F5D7B5FCD61"
BlueprintIdentifier = "11B0EF2E18D829262A7DF015BEBB0909"
BuildableName = "SignalServiceKit-Unit-Tests.xctest"
BlueprintName = "SignalServiceKit-Unit-Tests"
ReferencedContainer = "container:Pods/Pods.xcodeproj">

View file

@ -1,12 +1,17 @@
// Created by Michael Kirk on 12/18/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSCallMessageHandler.h"
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@interface OWSFakeCallMessageHandler : NSObject <OWSCallMessageHandler>
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,42 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSFakeCallMessageHandler.h"
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@implementation OWSFakeCallMessageHandler
- (void)receivedOffer:(SSKProtoCallMessageOffer *)offer fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)receivedAnswer:(SSKProtoCallMessageAnswer *)answer fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)receivedIceUpdate:(SSKProtoCallMessageIceUpdate *)iceUpdate fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)receivedHangup:(SSKProtoCallMessageHangup *)hangup fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)receivedBusy:(SSKProtoCallMessageBusy *)busy fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -1,12 +1,17 @@
// Created by Michael Kirk on 10/7/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "ContactsManagerProtocol.h"
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@interface OWSFakeContactsManager : NSObject <ContactsManagerProtocol>
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,42 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSFakeContactsManager.h"
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@implementation OWSFakeContactsManager
- (NSString *_Nonnull)displayNameForPhoneIdentifier:(NSString *_Nullable)phoneNumber
{
return @"Fake name";
}
- (NSArray<Contact *> *)signalContacts
{
return @[];
}
- (NSArray<SignalAccount *> *)signalAccounts
{
return @[];
}
+ (BOOL)name:(NSString *_Nonnull)nameString matchesQuery:(NSString *_Nonnull)queryString
{
return YES;
}
- (UIImage *_Nullable)imageForPhoneIdentifier:(NSString *_Nullable)phoneNumber
{
return nil;
}
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,21 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSMessageSender.h"
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@interface OWSFakeMessageSender : OWSMessageSender
@property (nonatomic, nullable) dispatch_block_t enqueueMessageBlock;
@property (nonatomic, nullable) dispatch_block_t enqueueAttachmentBlock;
@property (nonatomic, nullable) dispatch_block_t enqueueTemporaryAttachmentBlock;
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -0,0 +1,53 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSFakeMessageSender.h"
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@implementation OWSFakeMessageSender
- (void)enqueueMessage:(TSOutgoingMessage *)message
success:(void (^)(void))successHandler
failure:(void (^)(NSError *error))failureHandler
{
if (self.enqueueMessageBlock) {
self.enqueueMessageBlock();
}
successHandler();
}
- (void)enqueueAttachment:(DataSource *)dataSource
contentType:(NSString *)contentType
sourceFilename:(nullable NSString *)sourceFilename
inMessage:(TSOutgoingMessage *)outgoingMessage
success:(void (^)(void))successHandler
failure:(void (^)(NSError *error))failureHandler
{
if (self.enqueueAttachmentBlock) {
self.enqueueAttachmentBlock();
}
successHandler();
}
- (void)enqueueTemporaryAttachment:(DataSource *)dataSource
contentType:(NSString *)contentType
inMessage:(TSOutgoingMessage *)outgoingMessage
success:(void (^)(void))successHandler
failure:(void (^)(NSError *error))failureHandler
{
if (self.enqueueTemporaryAttachmentBlock) {
self.enqueueTemporaryAttachmentBlock();
}
successHandler();
}
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -1,12 +1,19 @@
// Created by Michael Kirk on 10/19/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "TSNetworkManager.h"
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@interface OWSFakeNetworkManager : TSNetworkManager
- (instancetype)init;
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -1,10 +1,13 @@
// Created by Michael Kirk on 10/19/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSFakeNetworkManager.h"
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@implementation OWSFakeNetworkManager
- (void)makeRequest:(TSRequest *)request
@ -16,4 +19,6 @@ NS_ASSUME_NONNULL_BEGIN
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -1,12 +1,17 @@
// Created by Michael Kirk on 12/18/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "NotificationsProtocol.h"
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@interface OWSFakeNotificationsManager : NSObject <NotificationsProtocol>
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -1,11 +1,13 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSFakeNotificationsManager.h"
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@implementation OWSFakeNotificationsManager
- (void)notifyUserForIncomingMessage:(TSIncomingMessage *)incomingMessage
@ -23,4 +25,6 @@ NS_ASSUME_NONNULL_BEGIN
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -1,13 +1,17 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "ProfileManagerProtocol.h"
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@interface OWSFakeProfileManager : NSObject <ProfileManagerProtocol>
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSFakeProfileManager.h"
@ -8,6 +8,8 @@
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@interface OWSFakeProfileManager ()
@property (nonatomic, readonly) NSMutableDictionary<NSString *, OWSAES256Key *> *profileKeys;
@ -68,4 +70,6 @@ NS_ASSUME_NONNULL_BEGIN
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -6,8 +6,12 @@
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@interface TestAppContext : NSObject <AppContext>
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -7,6 +7,8 @@
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@interface TestAppContext ()
@property (nonatomic) SSKTestKeychainStorage *testKeychainStorage;
@ -150,4 +152,6 @@ NS_ASSUME_NONNULL_BEGIN
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -4,6 +4,8 @@
import Foundation
#if DEBUG
@objc
public class SSKTestKeychainStorage: NSObject, SSKKeychainStorage {
@ -50,3 +52,5 @@ public class SSKTestKeychainStorage: NSObject, SSKKeychainStorage {
dataMap.removeValue(forKey: key)
}
}
#endif

View file

@ -6,8 +6,12 @@
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@interface SSKBaseTest : XCTestCase
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -9,6 +9,8 @@
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
@implementation SSKBaseTest
- (void)setUp
@ -35,4 +37,6 @@ NS_ASSUME_NONNULL_BEGIN
@end
#endif
NS_ASSUME_NONNULL_END

View file

@ -1,37 +0,0 @@
// Created by Michael Kirk on 12/18/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "OWSFakeCallMessageHandler.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSFakeCallMessageHandler
- (void)receivedOffer:(OWSSignalServiceProtosCallMessageOffer *)offer fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)receivedAnswer:(OWSSignalServiceProtosCallMessageAnswer *)answer fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)receivedIceUpdate:(OWSSignalServiceProtosCallMessageIceUpdate *)iceUpdate fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)receivedHangup:(OWSSignalServiceProtosCallMessageHangup *)hangup fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)receivedBusy:(OWSSignalServiceProtosCallMessageBusy *)busy fromCallerId:(NSString *)callerId
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
@end
NS_ASSUME_NONNULL_END

View file

@ -1,40 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSFakeContactsManager.h"
NS_ASSUME_NONNULL_BEGIN
@class UIImage;
@implementation OWSFakeContactsManager
- (NSString * _Nonnull)displayNameForPhoneIdentifier:(NSString * _Nullable)phoneNumber
{
return @"Fake name";
}
- (NSArray<Contact *> *)signalContacts
{
return @[];
}
- (NSArray<SignalAccount *> *)signalAccounts
{
return @[];
}
+ (BOOL)name:(NSString * _Nonnull)nameString matchesQuery:(NSString * _Nonnull)queryString
{
return YES;
}
- (UIImage * _Nullable)imageForPhoneIdentifier:(NSString * _Nullable)phoneNumber
{
return nil;
}
@end
NS_ASSUME_NONNULL_END

View file

@ -1,12 +0,0 @@
// Created by Michael Kirk on 10/7/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
#import "ContactsUpdater.h"
NS_ASSUME_NONNULL_BEGIN
@interface OWSFakeContactsUpdater : ContactsUpdater
@end
NS_ASSUME_NONNULL_END

View file

@ -1,21 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSFakeContactsUpdater.h"
#import "SignalRecipient.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSFakeContactsUpdater
- (nullable SignalRecipient *)synchronousLookup:(NSString *)identifier error:(NSError **)error
{
NSLog(@"[OWSFakeContactsUpdater] Faking contact lookup.");
return [[SignalRecipient alloc] initWithTextSecureIdentifier:@"fake-recipient-id"
relay:nil];
}
@end
NS_ASSUME_NONNULL_END

View file

@ -1,19 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSMessageSender.h"
#import <XCTest/XCTest.h>
NS_ASSUME_NONNULL_BEGIN
@interface OWSFakeMessageSender : OWSMessageSender
- (instancetype)init;
- (instancetype)initWithExpectation:(XCTestExpectation *)expectation;
@property (nonatomic, readonly) XCTestExpectation *expectation;
@end
NS_ASSUME_NONNULL_END

View file

@ -1,37 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSFakeMessageSender.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSFakeMessageSender
- (instancetype)initWithExpectation:(XCTestExpectation *)expectation
{
self = [self init];
if (!self) {
return self;
}
_expectation = expectation;
return self;
}
- (void)sendTemporaryAttachmentData:(NSData *)attachmentData
contentType:(NSString *)contentType
inMessage:(TSOutgoingMessage *)outgoingMessage
success:(void (^)())successHandler
failure:(void (^)(NSError *error))failureHandler
{
NSLog(@"Faking sendTemporyAttachmentData.");
[self.expectation fulfill];
successHandler();
}
@end
NS_ASSUME_NONNULL_END

View file

@ -1,16 +0,0 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "SSKEnvironment.h"
NS_ASSUME_NONNULL_BEGIN
@interface OWSUnitTestEnvironment : SSKEnvironment
+ (void)ensureSetup;
- (instancetype)initDefault;
@end
NS_ASSUME_NONNULL_END

View file

@ -1,35 +0,0 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSUnitTestEnvironment.h"
#import "OWSFakeCallMessageHandler.h"
#import "OWSFakeContactsManager.h"
#import "OWSFakeMessageSender.h"
#import "OWSFakeNotificationsManager.h"
#import "OWSFakeProfileManager.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSUnitTestEnvironment
+ (void)ensureSetup
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self setShared:[[self alloc] initDefault]];
});
}
- (instancetype)initDefault
{
return [super initWithCallMessageHandler:[OWSFakeCallMessageHandler new]
contactsManager:[OWSFakeContactsManager new]
messageSender:[OWSFakeMessageSender new]
notificationsManager:[OWSFakeNotificationsManager new]
profileManager:[OWSFakeProfileManager new]];
}
@end
NS_ASSUME_NONNULL_END