mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
2.8 KiB
Objective-C
165 lines
2.8 KiB
Objective-C
//
|
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "TestAppContext.h"
|
|
#import <SignalServiceKit/OWSFileSystem.h>
|
|
#import <SignalServiceKit/SignalServiceKit-Swift.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
#ifdef DEBUG
|
|
|
|
@interface TestAppContext ()
|
|
|
|
@property (nonatomic) SSKTestKeychainStorage *testKeychainStorage;
|
|
@property (nonatomic) NSString *mockAppDocumentDirectoryPath;
|
|
@property (nonatomic) NSString *mockAppSharedDataDirectoryPath;
|
|
@property (nonatomic) NSUserDefaults *appUserDefaults;
|
|
|
|
@end
|
|
|
|
#pragma mark -
|
|
|
|
@implementation TestAppContext
|
|
|
|
@synthesize mainWindow = _mainWindow;
|
|
@synthesize appLaunchTime = _appLaunchTime;
|
|
|
|
- (instancetype)init
|
|
{
|
|
self = [super init];
|
|
if (!self) {
|
|
return self;
|
|
}
|
|
|
|
self.testKeychainStorage = [SSKTestKeychainStorage new];
|
|
|
|
NSString *temporaryDirectory = OWSTemporaryDirectory();
|
|
self.mockAppDocumentDirectoryPath = [temporaryDirectory stringByAppendingPathComponent:NSUUID.UUID.UUIDString];
|
|
self.mockAppSharedDataDirectoryPath = [temporaryDirectory stringByAppendingPathComponent:NSUUID.UUID.UUIDString];
|
|
self.appUserDefaults = [[NSUserDefaults alloc] init];
|
|
_appLaunchTime = [NSDate new];
|
|
|
|
return self;
|
|
}
|
|
|
|
- (UIApplicationState)reportedApplicationState
|
|
{
|
|
return UIApplicationStateActive;
|
|
}
|
|
|
|
#pragma mark -
|
|
|
|
- (BOOL)isMainApp
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
- (BOOL)isMainAppAndActive
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
- (BOOL)isRTL
|
|
{
|
|
return NO;
|
|
}
|
|
|
|
- (void)setStatusBarHidden:(BOOL)isHidden animated:(BOOL)isAnimated
|
|
{
|
|
}
|
|
|
|
- (CGFloat)statusBarHeight
|
|
{
|
|
return 20;
|
|
}
|
|
|
|
- (BOOL)isInBackground
|
|
{
|
|
return NO;
|
|
}
|
|
|
|
- (BOOL)isAppForegroundAndActive
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:
|
|
(BackgroundTaskExpirationHandler)expirationHandler
|
|
{
|
|
return UIBackgroundTaskInvalid;
|
|
}
|
|
|
|
- (void)endBackgroundTask:(UIBackgroundTaskIdentifier)backgroundTaskIdentifier
|
|
{
|
|
}
|
|
|
|
- (void)ensureSleepBlocking:(BOOL)shouldBeBlocking blockingObjects:(NSArray<id> *)blockingObjects
|
|
{
|
|
}
|
|
|
|
- (void)setMainAppBadgeNumber:(NSInteger)value
|
|
{
|
|
}
|
|
|
|
- (nullable UIViewController *)frontmostViewController
|
|
{
|
|
return nil;
|
|
}
|
|
|
|
- (nullable UIAlertAction *)openSystemSettingsAction
|
|
{
|
|
return nil;
|
|
}
|
|
|
|
- (BOOL)isRunningTests
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
- (void)setNetworkActivityIndicatorVisible:(BOOL)value
|
|
{
|
|
}
|
|
|
|
#pragma mark -
|
|
|
|
- (void)runNowOrWhenMainAppIsActive:(AppActiveBlock)block
|
|
{
|
|
block();
|
|
}
|
|
|
|
- (void)runAppActiveBlocks
|
|
{
|
|
}
|
|
|
|
- (id<SSKKeychainStorage>)keychainStorage
|
|
{
|
|
return self.testKeychainStorage;
|
|
}
|
|
|
|
- (NSString *)appDocumentDirectoryPath
|
|
{
|
|
return self.mockAppDocumentDirectoryPath;
|
|
}
|
|
|
|
- (NSString *)appSharedDataDirectoryPath
|
|
{
|
|
return self.mockAppSharedDataDirectoryPath;
|
|
}
|
|
|
|
- (BOOL)isDebugBuild
|
|
{
|
|
#ifdef DEBUG
|
|
return YES;
|
|
#else
|
|
return NO;
|
|
#endif
|
|
}
|
|
|
|
@end
|
|
|
|
#endif
|
|
|
|
NS_ASSUME_NONNULL_END
|