mirror of https://github.com/oxen-io/session-ios
Merge branch 'charlesmchen/fix-ssk-tests-k2'
commit
68714b296c
@ -1 +1 @@
|
||||
Subproject commit 327edd6db716ef97af817b170155ed4b4487d891
|
||||
Subproject commit 6f5013b6f65fa1d988c9a2a027ea2b09f995ab95
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
Loading…
Reference in New Issue