diff --git a/Signal/src/environment/AppEnvironment.swift b/Signal/src/environment/AppEnvironment.swift index d3d025634..e35a59b01 100644 --- a/Signal/src/environment/AppEnvironment.swift +++ b/Signal/src/environment/AppEnvironment.swift @@ -50,46 +50,18 @@ import SignalMessaging public var pushRegistrationManager: PushRegistrationManager @objc - public init(callMessageHandler: WebRTCCallMessageHandler, - callService: CallService, - outboundCallInitiator: OutboundCallInitiator, - messageFetcherJob: MessageFetcherJob, - notificationsManager: NotificationsManager, - accountManager: AccountManager, - callNotificationsAdapter: CallNotificationsAdapter, - pushRegistrationManager: PushRegistrationManager) { - self.callMessageHandler = callMessageHandler - self.callService = callService - self.outboundCallInitiator = outboundCallInitiator - self.messageFetcherJob = messageFetcherJob - self.notificationsManager = notificationsManager - self.accountManager = accountManager - self.callNotificationsAdapter = callNotificationsAdapter - self.pushRegistrationManager = pushRegistrationManager - - super.init() - - SwiftSingletons.register(self) - } + public var pushManager: PushManager private override init() { - let accountManager = AccountManager() - let notificationsManager = NotificationsManager() - let callNotificationsAdapter = CallNotificationsAdapter() - let callService = CallService() - let callMessageHandler = WebRTCCallMessageHandler() - let outboundCallInitiator = OutboundCallInitiator() - let messageFetcherJob = MessageFetcherJob() - let pushRegistrationManager = PushRegistrationManager() - - self.callMessageHandler = callMessageHandler - self.callService = callService - self.outboundCallInitiator = outboundCallInitiator - self.messageFetcherJob = messageFetcherJob - self.notificationsManager = notificationsManager - self.accountManager = accountManager - self.callNotificationsAdapter = callNotificationsAdapter - self.pushRegistrationManager = pushRegistrationManager + self.callMessageHandler = WebRTCCallMessageHandler() + self.callService = CallService() + self.outboundCallInitiator = OutboundCallInitiator() + self.messageFetcherJob = MessageFetcherJob() + self.notificationsManager = NotificationsManager() + self.accountManager = AccountManager() + self.callNotificationsAdapter = CallNotificationsAdapter() + self.pushRegistrationManager = PushRegistrationManager() + self.pushManager = PushManager() super.init() diff --git a/Signal/src/environment/NotificationsManager.h b/Signal/src/environment/NotificationsManager.h index b7cf0bc2d..0d2523ed6 100644 --- a/Signal/src/environment/NotificationsManager.h +++ b/Signal/src/environment/NotificationsManager.h @@ -15,8 +15,6 @@ NS_ASSUME_NONNULL_BEGIN @interface NotificationsManager : NSObject -- (void)clearAllNotifications; - #ifdef DEBUG + (void)presentDebugNotification; diff --git a/Signal/src/network/PushManager.h b/Signal/src/network/PushManager.h index dc2e0c282..d977c265f 100644 --- a/Signal/src/network/PushManager.h +++ b/Signal/src/network/PushManager.h @@ -39,8 +39,6 @@ typedef void (^pushTokensSuccessBlock)(NSString *pushToken, NSString *voipToken) @property (nonatomic) BOOL hasPresentedConversationSinceLastDeactivation; -- (instancetype)init NS_UNAVAILABLE; - + (PushManager *)sharedManager; /** diff --git a/Signal/src/network/PushManager.m b/Signal/src/network/PushManager.m index 5933fe5f0..7031724e0 100644 --- a/Signal/src/network/PushManager.m +++ b/Signal/src/network/PushManager.m @@ -35,47 +35,26 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe @property (nonatomic) NSMutableArray *currentNotifications; @property (nonatomic) UIBackgroundTaskIdentifier callBackgroundTask; -@property (nonatomic, readonly) OWSMessageSender *messageSender; -@property (nonatomic, readonly) OWSMessageFetcherJob *messageFetcherJob; -@property (nonatomic, readonly) NotificationsManager *notificationsManager; @end @implementation PushManager + (instancetype)sharedManager { - static PushManager *sharedManager = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sharedManager = [[self alloc] initDefault]; - }); - return sharedManager; -} + OWSAssertDebug(AppEnvironment.shared.pushManager); -- (instancetype)initDefault -{ - return [self initWithMessageFetcherJob:AppEnvironment.shared.messageFetcherJob - primaryStorage:[OWSPrimaryStorage sharedManager] - messageSender:SSKEnvironment.shared.messageSender - notificationsManager:AppEnvironment.shared.notificationsManager]; + return AppEnvironment.shared.pushManager; } -- (instancetype)initWithMessageFetcherJob:(OWSMessageFetcherJob *)messageFetcherJob - primaryStorage:(OWSPrimaryStorage *)primaryStorage - messageSender:(OWSMessageSender *)messageSender - notificationsManager:(NotificationsManager *)notificationsManager -{ +- (instancetype)init { self = [super init]; if (!self) { return self; } - _messageSender = messageSender; - _messageFetcherJob = messageFetcherJob; _callBackgroundTask = UIBackgroundTaskInvalid; // TODO: consolidate notification tracking with NotificationsManager, which also maintains a list of notifications. _currentNotifications = [NSMutableArray array]; - _notificationsManager = notificationsManager; OWSSingletonAssert(); @@ -87,6 +66,22 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe return self; } +#pragma mark - Dependencies + +- (OWSMessageSender *)messageSender { + return SSKEnvironment.shared.messageSender; +} + +- (OWSMessageFetcherJob *)messageFetcherJob { + return AppEnvironment.shared.messageFetcherJob; +} + +- (id)notificationsManager { + return SSKEnvironment.shared.notificationsManager; +} + +#pragma mark - + - (CallUIAdapter *)callUIAdapter { return AppEnvironment.shared.callService.callUIAdapter; diff --git a/Signal/test/SignalBaseTest.m b/Signal/test/SignalBaseTest.m index d07e8ab9c..d15bd17c8 100644 --- a/Signal/test/SignalBaseTest.m +++ b/Signal/test/SignalBaseTest.m @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)setUp { - NSLog(@"%@ setUp", self.logTag); + OWSLogInfo(@""); [super setUp]; @@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)tearDown { - NSLog(@"%@ tearDown", self.logTag); + OWSLogInfo(@""); [super tearDown]; } diff --git a/Signal/test/util/OWSDatabaseConverterTest.m b/Signal/test/util/OWSDatabaseConverterTest.m index 60dfc24a1..c54518628 100644 --- a/Signal/test/util/OWSDatabaseConverterTest.m +++ b/Signal/test/util/OWSDatabaseConverterTest.m @@ -156,7 +156,7 @@ NS_ASSUME_NONNULL_BEGIN [self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error) { if (error) { - NSLog(@"Timeout Error: %@", error); + OWSLogInfo(@"Timeout Error: %@", error); } }]; } diff --git a/Signal/test/util/UtilTest.m b/Signal/test/util/UtilTest.m index 23bcd21fa..548879d52 100644 --- a/Signal/test/util/UtilTest.m +++ b/Signal/test/util/UtilTest.m @@ -103,7 +103,7 @@ NSDateFormatter *formatter = [NSDateFormatter new]; formatter.dateStyle = NSDateFormatterLongStyle; formatter.timeStyle = NSDateFormatterLongStyle; - NSLog(@"now: %@", [formatter stringFromDate:now]); + OWSLogInfo(@"now: %@", [formatter stringFromDate:now]); NSDate *oneSecondAgo = [NSDate dateWithTimeIntervalSinceReferenceDate:[now timeIntervalSinceReferenceDate] - kSecondInterval]; @@ -135,7 +135,7 @@ NSDate *twoYearsAhead = [NSDate dateWithTimeIntervalSinceReferenceDate:[now timeIntervalSinceReferenceDate] + kYearInterval * 2]; - NSLog(@"oneSecondAgo: %@", [formatter stringFromDate:oneSecondAgo]); + OWSLogInfo(@"oneSecondAgo: %@", [formatter stringFromDate:oneSecondAgo]); XCTAssertTrue([DateUtil dateIsToday:oneSecondAgo now:now]); XCTAssertTrue([DateUtil dateIsToday:oneMinuteAgo now:now]); @@ -236,13 +236,13 @@ formatter.timeStyle = NSDateFormatterLongStyle; NSDate *yesterdayBeforeMidnight = [self dateWithYear:2015 month:8 day:10 hour:23 minute:55]; - NSLog(@"yesterdayBeforeMidnight: %@", [formatter stringFromDate:yesterdayBeforeMidnight]); + OWSLogInfo(@"yesterdayBeforeMidnight: %@", [formatter stringFromDate:yesterdayBeforeMidnight]); NSDate *todayAfterMidnight = [self dateWithYear:2015 month:8 day:11 hour:0 minute:5]; - NSLog(@"todayAfterMidnight: %@", [formatter stringFromDate:todayAfterMidnight]); + OWSLogInfo(@"todayAfterMidnight: %@", [formatter stringFromDate:todayAfterMidnight]); NSDate *todayNoon = [self dateWithYear:2015 month:8 day:11 hour:12 minute:0]; - NSLog(@"todayNoon: %@", [formatter stringFromDate:todayNoon]); + OWSLogInfo(@"todayNoon: %@", [formatter stringFromDate:todayNoon]); // Before Midnight, after Midnight. XCTAssertFalse([DateUtil dateIsToday:yesterdayBeforeMidnight now:todayAfterMidnight]); diff --git a/SignalMessaging/environment/NoopNotificationsManager.swift b/SignalMessaging/environment/NoopNotificationsManager.swift index fc4cfe3bf..1f82c8d92 100644 --- a/SignalMessaging/environment/NoopNotificationsManager.swift +++ b/SignalMessaging/environment/NoopNotificationsManager.swift @@ -18,4 +18,8 @@ public class NoopNotificationsManager: NSObject, NotificationsProtocol { public func notifyUser(forThreadlessErrorMessage error: TSErrorMessage, transaction: YapDatabaseReadWriteTransaction) { Logger.warn("skipping notification for: \(error.description)") } + + public func clearAllNotifications() { + Logger.warn("clearAllNotifications") + } } diff --git a/SignalMessaging/environment/migrations/OWSDatabaseMigration.m b/SignalMessaging/environment/migrations/OWSDatabaseMigration.m index 56cf5eb6c..1a7c7702f 100644 --- a/SignalMessaging/environment/migrations/OWSDatabaseMigration.m +++ b/SignalMessaging/environment/migrations/OWSDatabaseMigration.m @@ -4,6 +4,7 @@ #import "OWSDatabaseMigration.h" #import +#import NS_ASSUME_NONNULL_BEGIN @@ -81,13 +82,7 @@ NS_ASSUME_NONNULL_BEGIN + (YapDatabaseConnection *)dbReadWriteConnection { - static dispatch_once_t onceToken; - static YapDatabaseConnection *sharedDBConnection; - dispatch_once(&onceToken, ^{ - sharedDBConnection = [OWSPrimaryStorage sharedManager].newDatabaseConnection; - }); - - return sharedDBConnection; + return SSKEnvironment.shared.migrationDBConnection; } - (YapDatabaseConnection *)dbReadConnection diff --git a/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m b/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m index 8bd41456e..1597449e3 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m @@ -220,12 +220,7 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt + (YapDatabaseConnection *)dbMigrationConnection { - static YapDatabaseConnection *connection = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - connection = [[OWSPrimaryStorage sharedManager] newDatabaseConnection]; - }); - return connection; + return SSKEnvironment.shared.migrationDBConnection; } + (instancetype)outgoingMessageInThread:(nullable TSThread *)thread diff --git a/SignalServiceKit/src/Protocols/NotificationsProtocol.h b/SignalServiceKit/src/Protocols/NotificationsProtocol.h index a113d2567..7bb14ea2b 100644 --- a/SignalServiceKit/src/Protocols/NotificationsProtocol.h +++ b/SignalServiceKit/src/Protocols/NotificationsProtocol.h @@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)notifyUserForThreadlessErrorMessage:(TSErrorMessage *)error transaction:(YapDatabaseReadWriteTransaction *)transaction; +- (void)clearAllNotifications; + @end NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/SSKEnvironment.h b/SignalServiceKit/src/SSKEnvironment.h index 53495deae..02d6e04c9 100644 --- a/SignalServiceKit/src/SSKEnvironment.h +++ b/SignalServiceKit/src/SSKEnvironment.h @@ -90,6 +90,9 @@ NS_ASSUME_NONNULL_BEGIN @property (atomic, nullable) id notificationsManager; @property (atomic, readonly) YapDatabaseConnection *objectReadWriteConnection; +@property (atomic, readonly) YapDatabaseConnection *sessionStoreDBConnection; +@property (atomic, readonly) YapDatabaseConnection *migrationDBConnection; +@property (atomic, readonly) YapDatabaseConnection *analyticsDBConnection; - (BOOL)isComplete; diff --git a/SignalServiceKit/src/SSKEnvironment.m b/SignalServiceKit/src/SSKEnvironment.m index 8bcb13e83..8aefcc811 100644 --- a/SignalServiceKit/src/SSKEnvironment.m +++ b/SignalServiceKit/src/SSKEnvironment.m @@ -42,6 +42,9 @@ static SSKEnvironment *sharedSSKEnvironment; @synthesize callMessageHandler = _callMessageHandler; @synthesize notificationsManager = _notificationsManager; @synthesize objectReadWriteConnection = _objectReadWriteConnection; +@synthesize sessionStoreDBConnection = _sessionStoreDBConnection; +@synthesize migrationDBConnection = _migrationDBConnection; +@synthesize analyticsDBConnection = _analyticsDBConnection; - (instancetype)initWithContactsManager:(id)contactsManager messageSender:(OWSMessageSender *)messageSender @@ -188,6 +191,34 @@ static SSKEnvironment *sharedSSKEnvironment; return _objectReadWriteConnection; } } + +- (YapDatabaseConnection *)sessionStoreDBConnection { + @synchronized(self) { + if (!_sessionStoreDBConnection) { + _sessionStoreDBConnection = self.primaryStorage.newDatabaseConnection; + } + return _sessionStoreDBConnection; + } +} + +- (YapDatabaseConnection *)migrationDBConnection { + @synchronized(self) { + if (!_migrationDBConnection) { + _migrationDBConnection = self.primaryStorage.newDatabaseConnection; + } + return _migrationDBConnection; + } +} + +- (YapDatabaseConnection *)analyticsDBConnection { + @synchronized(self) { + if (!_analyticsDBConnection) { + _analyticsDBConnection = self.primaryStorage.newDatabaseConnection; + } + return _analyticsDBConnection; + } +} + @end NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SessionStore.m b/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SessionStore.m index ec4ff7413..86acee97f 100644 --- a/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SessionStore.m +++ b/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SessionStore.m @@ -2,8 +2,9 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "OWSPrimaryStorage+SessionStore.h" #import "OWSFileSystem.h" +#import "OWSPrimaryStorage+SessionStore.h" +#import "SSKEnvironment.h" #import "YapDatabaseConnection+OWS.h" #import "YapDatabaseTransaction+OWS.h" #import @@ -23,14 +24,7 @@ NSString *const kSessionStoreDBConnectionKey = @"kSessionStoreDBConnectionKey"; */ + (YapDatabaseConnection *)sessionStoreDBConnection { - static dispatch_once_t onceToken; - static YapDatabaseConnection *sessionStoreDBConnection; - dispatch_once(&onceToken, ^{ - sessionStoreDBConnection = [OWSPrimaryStorage sharedManager].newDatabaseConnection; - sessionStoreDBConnection.objectCacheEnabled = NO; - }); - - return sessionStoreDBConnection; + return SSKEnvironment.shared.sessionStoreDBConnection; } - (YapDatabaseConnection *)sessionStoreDBConnection diff --git a/SignalServiceKit/src/TestUtils/OWSFakeCallMessageHandler.m b/SignalServiceKit/src/TestUtils/OWSFakeCallMessageHandler.m index 5925468c4..06cd641f6 100644 --- a/SignalServiceKit/src/TestUtils/OWSFakeCallMessageHandler.m +++ b/SignalServiceKit/src/TestUtils/OWSFakeCallMessageHandler.m @@ -12,27 +12,27 @@ NS_ASSUME_NONNULL_BEGIN - (void)receivedOffer:(SSKProtoCallMessageOffer *)offer fromCallerId:(NSString *)callerId { - NSLog(@"%s", __PRETTY_FUNCTION__); + OWSLogInfo(@""); } - (void)receivedAnswer:(SSKProtoCallMessageAnswer *)answer fromCallerId:(NSString *)callerId { - NSLog(@"%s", __PRETTY_FUNCTION__); + OWSLogInfo(@""); } - (void)receivedIceUpdate:(SSKProtoCallMessageIceUpdate *)iceUpdate fromCallerId:(NSString *)callerId { - NSLog(@"%s", __PRETTY_FUNCTION__); + OWSLogInfo(@""); } - (void)receivedHangup:(SSKProtoCallMessageHangup *)hangup fromCallerId:(NSString *)callerId { - NSLog(@"%s", __PRETTY_FUNCTION__); + OWSLogInfo(@""); } - (void)receivedBusy:(SSKProtoCallMessageBusy *)busy fromCallerId:(NSString *)callerId { - NSLog(@"%s", __PRETTY_FUNCTION__); + OWSLogInfo(@""); } @end diff --git a/SignalServiceKit/src/TestUtils/OWSFakeContactsUpdater.m b/SignalServiceKit/src/TestUtils/OWSFakeContactsUpdater.m index 3fc0a2431..9b3373777 100644 --- a/SignalServiceKit/src/TestUtils/OWSFakeContactsUpdater.m +++ b/SignalServiceKit/src/TestUtils/OWSFakeContactsUpdater.m @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN //- (nullable SignalRecipient *)synchronousLookup:(NSString *)identifier error:(NSError **)error //{ -// NSLog(@"[OWSFakeContactsUpdater] Faking contact lookup."); +// OWSLogInfo(@"[OWSFakeContactsUpdater] Faking contact lookup."); // return [[SignalRecipient alloc] initWithTextSecureIdentifier:@"fake-recipient-id" // relay:nil]; //} diff --git a/SignalServiceKit/src/TestUtils/OWSFakeNotificationsManager.m b/SignalServiceKit/src/TestUtils/OWSFakeNotificationsManager.m index f42c63d61..8d47849d2 100644 --- a/SignalServiceKit/src/TestUtils/OWSFakeNotificationsManager.m +++ b/SignalServiceKit/src/TestUtils/OWSFakeNotificationsManager.m @@ -13,15 +13,24 @@ NS_ASSUME_NONNULL_BEGIN - (void)notifyUserForIncomingMessage:(TSIncomingMessage *)incomingMessage inThread:(TSThread *)thread contactsManager:(id)contactsManager -{ - NSLog(@"%s", __PRETTY_FUNCTION__); + transaction:(YapDatabaseReadTransaction *)transaction { + OWSLogInfo(@""); } -- (void)notifyUserForErrorMessage:(TSErrorMessage *)error inThread:(TSThread *)thread -{ - NSLog(@"%s", __PRETTY_FUNCTION__); +- (void)notifyUserForErrorMessage:(TSErrorMessage *)error + thread:(TSThread *)thread + transaction:(YapDatabaseReadWriteTransaction *)transaction { + OWSLogInfo(@""); } +- (void)notifyUserForThreadlessErrorMessage:(TSErrorMessage *)error + transaction:(YapDatabaseReadWriteTransaction *)transaction { + OWSLogInfo(@""); +} + +- (void)clearAllNotifications { + OWSLogInfo(@""); +} @end diff --git a/SignalServiceKit/src/Util/OWSAnalytics.m b/SignalServiceKit/src/Util/OWSAnalytics.m index c64156da6..eeb3db384 100755 --- a/SignalServiceKit/src/Util/OWSAnalytics.m +++ b/SignalServiceKit/src/Util/OWSAnalytics.m @@ -7,6 +7,7 @@ #import "OWSBackgroundTask.h" #import "OWSPrimaryStorage.h" #import "OWSQueues.h" +#import "SSKEnvironment.h" #import "YapDatabaseConnection+OWS.h" #import #import @@ -66,15 +67,7 @@ NSString *NSStringForOWSAnalyticsSeverity(OWSAnalyticsSeverity severity) // errors that occur while initializing OWSPrimaryStorage. + (YapDatabaseConnection *)dbConnection { - static YapDatabaseConnection *instance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - OWSPrimaryStorage *primaryStorage = [OWSPrimaryStorage sharedManager]; - OWSAssertDebug(primaryStorage); - // Use a newDatabaseConnection so as not to block reads in the launch path. - instance = primaryStorage.newDatabaseConnection; - }); - return instance; + return SSKEnvironment.shared.analyticsDBConnection; } - (instancetype)initDefault diff --git a/SignalServiceKit/tests/Devices/OWSDeviceProvisionerTest.m b/SignalServiceKit/tests/Devices/OWSDeviceProvisionerTest.m index 15fa17fc7..b7e7a8378 100644 --- a/SignalServiceKit/tests/Devices/OWSDeviceProvisionerTest.m +++ b/SignalServiceKit/tests/Devices/OWSDeviceProvisionerTest.m @@ -20,7 +20,7 @@ success:(void (^)())successCallback failure:(void (^)(NSError *))failureCallback { - NSLog(@"faking successful provisioning"); + OWSLogInfo(@"faking successful provisioning"); successCallback(); } @@ -35,7 +35,7 @@ - (void)requestProvisioningCodeWithSuccess:(void (^)(NSString *))successCallback failure:(void (^)(NSError *))failureCallback { - NSLog(@"faking successful provisioning code fetching"); + OWSLogInfo(@"faking successful provisioning code fetching"); successCallback(@"fake-provisioning-code"); } @@ -90,7 +90,7 @@ [self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error) { if (error) { - NSLog(@"Timeout Error: %@", error); + OWSLogInfo(@"Timeout Error: %@", error); } }]; } diff --git a/SignalServiceKit/tests/Messages/OWSMessageManagerTest.m b/SignalServiceKit/tests/Messages/OWSMessageManagerTest.m index 7bd77172f..4aad9499d 100644 --- a/SignalServiceKit/tests/Messages/OWSMessageManagerTest.m +++ b/SignalServiceKit/tests/Messages/OWSMessageManagerTest.m @@ -86,7 +86,7 @@ NS_ASSUME_NONNULL_BEGIN [self waitForExpectationsWithTimeout:5 handler:^(NSError *error) { - NSLog(@"No message submitted."); + OWSLogInfo(@"No message submitted."); }]; } diff --git a/SignalServiceKit/tests/Messages/OWSMessageSenderTest.m b/SignalServiceKit/tests/Messages/OWSMessageSenderTest.m index 6881d79eb..ef03ec699 100644 --- a/SignalServiceKit/tests/Messages/OWSMessageSenderTest.m +++ b/SignalServiceKit/tests/Messages/OWSMessageSenderTest.m @@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN forRecipient:(SignalRecipient *)recipient inThread:(TSThread *)thread { - NSLog(@"[OWSFakeMessagesManager] Faking deviceMessages."); + OWSLogInfo(@"[OWSFakeMessagesManager] Faking deviceMessages."); return @[]; } @@ -298,7 +298,7 @@ NS_ASSUME_NONNULL_BEGIN [self waitForExpectationsWithTimeout:5 handler:^(NSError *error) { - NSLog(@"Expiration timer not set in time."); + OWSLogInfo(@"Expiration timer not set in time."); }]; } @@ -324,7 +324,7 @@ NS_ASSUME_NONNULL_BEGIN [self waitForExpectationsWithTimeout:5 handler:^(NSError *error) { - NSLog(@"Expiration timer not set in time."); + OWSLogInfo(@"Expiration timer not set in time."); }]; } diff --git a/SignalServiceKit/tests/SSKBaseTestObjC.m b/SignalServiceKit/tests/SSKBaseTestObjC.m index f1f2bc026..bd7d85e0d 100644 --- a/SignalServiceKit/tests/SSKBaseTestObjC.m +++ b/SignalServiceKit/tests/SSKBaseTestObjC.m @@ -7,6 +7,9 @@ #import "SSKEnvironment.h" #import "TestAppContext.h" +@import CocoaLumberjack; +#import + NS_ASSUME_NONNULL_BEGIN #ifdef DEBUG @@ -15,10 +18,12 @@ NS_ASSUME_NONNULL_BEGIN - (void)setUp { - NSLog(@"%@ setUp", self.logTag); + OWSLogInfo(@"%@ setUp", self.logTag); [super setUp]; + [DDLog addLogger:DDTTYLogger.sharedInstance]; + ClearCurrentAppContextForTests(); SetCurrentAppContext([TestAppContext new]); @@ -27,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)tearDown { - NSLog(@"%@ tearDown", self.logTag); + OWSLogInfo(@"%@ tearDown", self.logTag); [super tearDown]; } diff --git a/SignalServiceKit/tests/SSKBaseTestSwift.swift b/SignalServiceKit/tests/SSKBaseTestSwift.swift index 9334140fc..aa928b35a 100644 --- a/SignalServiceKit/tests/SSKBaseTestSwift.swift +++ b/SignalServiceKit/tests/SSKBaseTestSwift.swift @@ -4,6 +4,7 @@ import XCTest import SignalServiceKit +import CocoaLumberjack @objc public class SSKBaseTestSwift: XCTestCase { @@ -12,6 +13,8 @@ public class SSKBaseTestSwift: XCTestCase { public override func setUp() { super.setUp() + DDLog.add(DDTTYLogger.sharedInstance) + ClearCurrentAppContextForTests() SetCurrentAppContext(TestAppContext())