未验证 提交 7186b390 编写于 作者: P Philipp Hofmann 提交者: GitHub

Merge branch 'master' into fix/subclasses-crash

......@@ -228,6 +228,7 @@
71F116E8F40D530BB68A2987 /* SentryCrashUUIDConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 71F11CDEF5952DF5CC69AC74 /* SentryCrashUUIDConversion.h */; };
7B0002322477F0520035FEF1 /* SentrySessionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B0002312477F0520035FEF1 /* SentrySessionTests.m */; };
7B0002342477F52D0035FEF1 /* SentrySessionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B0002332477F52D0035FEF1 /* SentrySessionTests.swift */; };
7B01CE3D271993AC00B5AF31 /* SentryTransportFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B01CE3C271993AB00B5AF31 /* SentryTransportFactoryTests.swift */; };
7B04A9AB24EA5F8D00E710B1 /* SentryUserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B04A9AA24EA5F8D00E710B1 /* SentryUserTests.swift */; };
7B04A9AF24EAC02C00E710B1 /* SentryRetryAfterHeaderParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BBD189C244EC71A00427C76 /* SentryRetryAfterHeaderParser.h */; };
7B05A61824A4D14A00EF211D /* SentrySessionGeneratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B05A61724A4D14A00EF211D /* SentrySessionGeneratorTests.swift */; };
......@@ -776,6 +777,7 @@
71F11CDEF5952DF5CC69AC74 /* SentryCrashUUIDConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashUUIDConversion.h; sourceTree = "<group>"; };
7B0002312477F0520035FEF1 /* SentrySessionTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySessionTests.m; sourceTree = "<group>"; };
7B0002332477F52D0035FEF1 /* SentrySessionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySessionTests.swift; sourceTree = "<group>"; };
7B01CE3C271993AB00B5AF31 /* SentryTransportFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryTransportFactoryTests.swift; sourceTree = "<group>"; };
7B04A9AA24EA5F8D00E710B1 /* SentryUserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUserTests.swift; sourceTree = "<group>"; };
7B05A61724A4D14A00EF211D /* SentrySessionGeneratorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySessionGeneratorTests.swift; sourceTree = "<group>"; };
7B0A54212521C21E00A71716 /* SentryFrameRemover.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryFrameRemover.h; path = include/SentryFrameRemover.h; sourceTree = "<group>"; };
......@@ -1932,6 +1934,7 @@
8E67F52E26B0EE6200A07CB5 /* TestURLSession.h */,
8E67F52F26B0EE6200A07CB5 /* TestURLSession.m */,
7B4D308926FC616B00C94DE9 /* SentryHttpTransportTests.swift */,
7B01CE3C271993AB00B5AF31 /* SentryTransportFactoryTests.swift */,
);
path = Networking;
sourceTree = "<group>";
......@@ -2557,6 +2560,7 @@
63B819141EC352A7002FDF4C /* SentryInterfacesTests.m in Sources */,
7B14089A248791660035403D /* SentryCrashStackEntryMapperTests.swift in Sources */,
7B869EBC249B91D8004F4FDB /* SentryDebugMetaEquality.swift in Sources */,
7B01CE3D271993AC00B5AF31 /* SentryTransportFactoryTests.swift in Sources */,
7B30B68026527C3C006B2752 /* SentryFramesTrackerTests.swift in Sources */,
7BC3937425B1ACB7004F03D3 /* SentryLevelMapperTests.swift in Sources */,
63FE720E20DA66EC00CDBAE8 /* SentryCrashCString_Tests.m in Sources */,
......
......@@ -16,6 +16,8 @@
#import "SentryUIViewControllerPerformanceTracker.h"
#import <SentryScreenFrames.h>
NS_ASSUME_NONNULL_BEGIN
static const void *spanTimestampObserver = &spanTimestampObserver;
/**
......@@ -141,17 +143,17 @@ static BOOL appStartMeasurementRead;
return self.rootSpan.context;
}
- (NSDate *)timestamp
- (nullable NSDate *)timestamp
{
return self.rootSpan.timestamp;
}
- (void)setTimestamp:(NSDate *)timestamp
- (void)setTimestamp:(nullable NSDate *)timestamp
{
self.rootSpan.timestamp = timestamp;
}
- (NSDate *)startTimestamp
- (nullable NSDate *)startTimestamp
{
return self.rootSpan.startTimestamp;
}
......@@ -170,7 +172,7 @@ static BOOL appStartMeasurementRead;
return _traceState;
}
- (void)setStartTimestamp:(NSDate *)startTimestamp
- (void)setStartTimestamp:(nullable NSDate *)startTimestamp
{
self.rootSpan.startTimestamp = startTimestamp;
......@@ -179,7 +181,7 @@ static BOOL appStartMeasurementRead;
#endif
}
- (NSDictionary<NSString *, id> *)data
- (nullable NSDictionary<NSString *, id> *)data
{
return self.rootSpan.data;
}
......@@ -194,7 +196,7 @@ static BOOL appStartMeasurementRead;
return self.rootSpan.isFinished;
}
- (void)setDataValue:(id)value forKey:(NSString *)key
- (void)setDataValue:(nullable id)value forKey:(NSString *)key
{
[self.rootSpan setDataValue:value forKey:key];
}
......@@ -351,24 +353,29 @@ static BOOL appStartMeasurementRead;
- (NSArray<SentrySpan *> *)buildAppStartSpans:
(nullable SentryAppStartMeasurement *)appStartMeasurement
{
if (appStartMeasurement == nil || appStartMeasurement.type == SentryAppStartTypeUnknown) {
if (appStartMeasurement == nil) {
return @[];
}
NSDate *appStartEndTimestamp = [appStartMeasurement.appStartTimestamp
dateByAddingTimeInterval:appStartMeasurement.duration];
NSString *operation;
NSString *type;
if (appStartMeasurement.type == SentryAppStartTypeCold) {
switch (appStartMeasurement.type) {
case SentryAppStartTypeCold:
operation = @"app.start.cold";
type = @"Cold Start";
} else if (appStartMeasurement.type == SentryAppStartTypeWarm) {
break;
case SentryAppStartTypeWarm:
operation = @"app.start.warm";
type = @"Warm Start";
break;
default:
return @[];
}
NSDate *appStartEndTimestamp = [appStartMeasurement.appStartTimestamp
dateByAddingTimeInterval:appStartMeasurement.duration];
SentrySpan *appStartSpan = [self buildSpan:_rootSpan.context.spanId
operation:operation
description:type];
......@@ -489,3 +496,5 @@ static BOOL appStartMeasurementRead;
}
@end
NS_ASSUME_NONNULL_END
import Foundation
class UrlSessionDelegateSpy: NSObject, URLSessionDelegate {
var delegateCalled = false
var delegateCallback : () -> Void = {}
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
delegateCalled = true
delegateCallback()
}
}
import Sentry
import XCTest
class SentryTransportFactoryTests: XCTestCase {
private static let dsnAsString = TestConstants.dsnAsString(username: "SentryTransportFactoryTests")
func testIntegration_UrlSessionDelegate_PassedToRequestManager() {
let urlSessionDelegateSpy = UrlSessionDelegateSpy()
let expect = expectation(description: "UrlSession Delegate of Options called in RequestManager")
urlSessionDelegateSpy.delegateCallback = {
expect.fulfill()
}
let options = Options()
options.dsn = SentryTransportFactoryTests.dsnAsString
options.urlSessionDelegate = urlSessionDelegateSpy
let fileManager = try! SentryFileManager(options: options, andCurrentDateProvider: TestCurrentDateProvider())
let transport = TransportInitializer.initTransport(options, sentryFileManager: fileManager)
let requestManager = Dynamic(transport).requestManager.asObject as! SentryQueueableRequestManager
let imgUrl = URL(string: "https://github.com")!
let request = URLRequest(url: imgUrl)
requestManager.add(request) { _, _ in /* We don't care about the result */ }
wait(for: [expect], timeout: 10)
}
}
......@@ -147,25 +147,6 @@ class SentrySDKTests: XCTestCase {
XCTAssertTrue(wasBeforeSendCalled, "beforeSend was not called.")
}
func testStartWithConfigureOptions_UrlSessionDelegate() {
let urlSessionDelegateSpy = UrlSessionDelegateSpy()
let predicate = NSPredicate { (_, _) -> Bool in
urlSessionDelegateSpy.delegateCalled
}
let expectation = self.expectation(for: predicate, evaluatedWith: nil)
expectation.expectationDescription = "urlSession_didReceive_completionHandler will be called on UrlSessionDelegateSpy"
SentrySDK.start { options in
options.dsn = SentrySDKTests.dsnAsString
options.urlSessionDelegate = urlSessionDelegateSpy
}
SentrySDK.capture(message: "")
wait(for: [expectation], timeout: 10)
}
func testCrashedLastRun() {
XCTAssertEqual(SentryCrash.sharedInstance().crashedLastLaunch, SentrySDK.crashedLastRun)
......
......@@ -70,7 +70,12 @@ class SentryScopeSwiftTests: XCTestCase {
}
}
private let fixture = Fixture()
private var fixture: Fixture!
override func setUp() {
super.setUp()
fixture = Fixture()
}
func testSerialize() {
let scope = fixture.scope
......
......@@ -80,6 +80,7 @@
#import "SentryOutOfMemoryLogic.h"
#import "SentryOutOfMemoryTracker.h"
#import "SentryPerformanceTracker.h"
#import "SentryQueueableRequestManager.h"
#import "SentryRandom.h"
#import "SentryRateLimitCategory.h"
#import "SentryRateLimitCategoryMapper.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册