mirror of https://github.com/oxen-io/session-ios
Move fakes to SSK/tests.
parent
45ff1979a3
commit
e784f9feeb
@ -1,5 +1,6 @@
|
||||
// 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"
|
||||
|
@ -1,5 +1,6 @@
|
||||
// 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"
|
||||
|
@ -0,0 +1,17 @@
|
||||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSMessageSender.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@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
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,49 @@
|
||||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSFakeMessageSender.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@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
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -1,5 +1,6 @@
|
||||
// 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"
|
||||
|
@ -1,5 +1,6 @@
|
||||
// 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"
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSFakeNotificationsManager.h"
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ProfileManagerProtocol.h"
|
@ -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"
|
@ -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