Signal-iOS/SignalServiceKit/tests/SSKBaseTestObjC.m
Evan Hahn 6305cdc0e6
SignalServiceKit: no longer a separate pod
SignalServiceKit is currently a separate pod. This makes merges tedious
and error-prone. Ultimately, it slows us down. It might've made sense as
a standalone library before, but it's so tightly integrated now that it
isn't useful to have it be separate.

This changes that, and makes SignalServiceKit a "normal" target.

IMO, most of this change isn't that exciting—just a bunch of changes to
scaffolding. There's one slightly spicier change: our generated
`Acknowledgements.plist` is now a little more clever.

Co-authored-by: Max Radermacher <max@signal.org>
2022-08-05 16:14:15 -05:00

67 lines
1.4 KiB
Objective-C

//
// Copyright (c) 2022 Open Whisper Systems. All rights reserved.
//
#import "SSKBaseTestObjC.h"
#import "SDSDatabaseStorage+Objc.h"
#import "SSKEnvironment.h"
#import "TestAppContext.h"
#import <CocoaLumberjack/CocoaLumberjack.h>
#import <CocoaLumberjack/DDTTYLogger.h>
#import <SignalCoreKit/OWSAsserts.h>
#import <SignalCoreKit/OWSLogs.h>
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
#ifdef TESTABLE_BUILD
@implementation SSKBaseTestObjC
- (void)setUp
{
OWSLogInfo(@"setUp");
[super setUp];
[DDLog addLogger:DDTTYLogger.sharedInstance];
ClearCurrentAppContextForTests();
SetCurrentAppContext([TestAppContext new]);
[MockSSKEnvironment activate];
[GroupManager forceV1Groups];
}
- (void)tearDown
{
OWSLogInfo(@"tearDown");
OWSAssertIsOnMainThread();
// Spin the main run loop to flush any remaining async work.
__block BOOL done = NO;
dispatch_async(dispatch_get_main_queue(), ^{ done = YES; });
while (!done) {
(void)CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, true);
}
[super tearDown];
}
-(void)readWithBlock:(void (^)(SDSAnyReadTransaction *))block
{
[SDSDatabaseStorage.shared readWithBlock:block];
}
-(void)writeWithBlock:(void (^)(SDSAnyWriteTransaction *))block
{
DatabaseStorageWrite(SDSDatabaseStorage.shared, block);
}
@end
#endif
NS_ASSUME_NONNULL_END