mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-05-05 12:07:28 +00:00
Fix iOS 7.1 unit test and make upload more robust
This commit is contained in:
@@ -1590,6 +1590,8 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
* @param xml The XML data that needs to be send to the server
|
||||
*/
|
||||
- (void)sendCrashReportWithFilename:(NSString *)filename xml:(NSString*)xml attachment:(BITHockeyAttachment *)attachment {
|
||||
BOOL sendingWithURLSession = NO;
|
||||
|
||||
id nsurlsessionClass = NSClassFromString(@"NSURLSessionUploadTask");
|
||||
if (nsurlsessionClass && !bit_isRunningInAppExtension()) {
|
||||
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
|
||||
@@ -1598,20 +1600,24 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
NSURLRequest *request = [self requestWithBoundary:kBITHockeyAppClientBoundary];
|
||||
NSData *data = [self postBodyWithXML:xml attachment:attachment boundary:kBITHockeyAppClientBoundary];
|
||||
|
||||
__weak typeof (self) weakSelf = self;
|
||||
NSURLSessionUploadTask *uploadTask = [session uploadTaskWithRequest:request
|
||||
fromData:data
|
||||
completionHandler:^(NSData *responseData, NSURLResponse *response, NSError *error) {
|
||||
typeof (self) strongSelf = weakSelf;
|
||||
|
||||
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*) response;
|
||||
NSInteger statusCode = [httpResponse statusCode];
|
||||
[strongSelf processUploadResultWithFilename:filename responseData:responseData statusCode:statusCode error:error];
|
||||
}];
|
||||
|
||||
// 5
|
||||
[uploadTask resume];
|
||||
} else {
|
||||
if (request && data) {
|
||||
__weak typeof (self) weakSelf = self;
|
||||
NSURLSessionUploadTask *uploadTask = [session uploadTaskWithRequest:request
|
||||
fromData:data
|
||||
completionHandler:^(NSData *responseData, NSURLResponse *response, NSError *error) {
|
||||
typeof (self) strongSelf = weakSelf;
|
||||
|
||||
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*) response;
|
||||
NSInteger statusCode = [httpResponse statusCode];
|
||||
[strongSelf processUploadResultWithFilename:filename responseData:responseData statusCode:statusCode error:error];
|
||||
}];
|
||||
|
||||
[uploadTask resume];
|
||||
sendingWithURLSession = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sendingWithURLSession) {
|
||||
NSMutableURLRequest *request = [self requestWithBoundary:kBITHockeyAppClientBoundary];
|
||||
|
||||
NSData *postBody = [self postBodyWithXML:xml attachment:attachment boundary:kBITHockeyAppClientBoundary];
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#import "BITHockeyBaseManagerPrivate.h"
|
||||
|
||||
#import "BITTestHelper.h"
|
||||
#import "BITHockeyAppClient.h"
|
||||
|
||||
|
||||
#define kBITCrashMetaAttachment @"BITCrashMetaAttachment"
|
||||
|
||||
@@ -32,6 +34,7 @@
|
||||
|
||||
@implementation BITCrashManagerTests {
|
||||
BITCrashManager *_sut;
|
||||
BITHockeyAppClient *_hockeyAppClient;
|
||||
BOOL _startManagerInitialized;
|
||||
}
|
||||
|
||||
@@ -40,6 +43,11 @@
|
||||
|
||||
_startManagerInitialized = NO;
|
||||
_sut = [[BITCrashManager alloc] initWithAppIdentifier:nil isAppStoreEnvironment:NO];
|
||||
|
||||
_hockeyAppClient = [[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString: BITHOCKEYSDK_URL]];
|
||||
_hockeyAppClient.baseURL = [NSURL URLWithString:BITHOCKEYSDK_URL];
|
||||
|
||||
[_sut setHockeyAppClient:_hockeyAppClient];
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
|
||||
Reference in New Issue
Block a user