mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Pr/fix unit tests memory leaks (#1795)
* Fix some concurrency problems detected by Xcode 8's new Thread Sanitizer. Some of these changes are arguably just to silence the warnings from Thread Sanitizer. * Fix several memory leaks in the unit tests. A number of the unit test source files are compield with `-fno-objc-arc`. This was clearly overlooked when writing several of the unit tests. Fixed by (mostly) switching to use of `-autorelease` for the problem code. NOTE: This commit doesn't fix all the memory leaks found. There's still at least one leak in `-[ASDisplayNodeTests testSetNeedsDataFetchImmediateState]`, and several leaks in `ASBasicImageDownloader.mm`. I wasn't able to find a trivial cause to these, unfortunately.
This commit is contained in:
@@ -90,8 +90,22 @@ static BOOL ASRunRunLoopUntilBlockIsTrue(BOOL (^block)())
|
||||
{
|
||||
[super setUp];
|
||||
|
||||
_mockCache = [OCMockObject mockForProtocol:@protocol(ASImageCacheProtocol)];
|
||||
_mockDownloader = [OCMockObject mockForProtocol:@protocol(ASImageDownloaderProtocol)];
|
||||
_mockCache = [[OCMockObject mockForProtocol:@protocol(ASImageCacheProtocol)] retain];
|
||||
_mockDownloader = [[OCMockObject mockForProtocol:@protocol(ASImageDownloaderProtocol)] retain];
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
{
|
||||
if(_mockCache) {
|
||||
[_mockCache release];
|
||||
_mockCache = nil;
|
||||
}
|
||||
if(_mockDownloader) {
|
||||
[_mockDownloader release];
|
||||
_mockDownloader = nil;
|
||||
}
|
||||
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (void)testDataSourceImageMethod
|
||||
|
||||
Reference in New Issue
Block a user