Skip to content

Commit

Permalink
Add corrupted envelope ui test
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich committed Oct 8, 2024
1 parent 7033e0a commit 8ee95e2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 16 deletions.
9 changes: 9 additions & 0 deletions Samples/iOS-Swift/.maestro/corrupt-envelope.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
appId: io.sentry.sample.iOS-Swift
---
- launchApp
- tapOn: "Extra"
- tapOn: "Corrupt Envelope"
- tapOn: "Close SDK"
- tapOn: "Corrupt Envelope"
- stopApp
- launchApp
40 changes: 24 additions & 16 deletions Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -903,10 +903,10 @@
<rect key="frame" x="8" y="134" width="304" height="401"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="Yzg-QH-aPg">
<rect key="frame" x="0.0" y="0.0" width="304" height="252"/>
<rect key="frame" x="0.0" y="0.0" width="304" height="280"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" translatesAutoresizingMaskIntoConstraints="NO" id="FaL-DP-Rl6">
<rect key="frame" x="0.0" y="0.0" width="152" height="252"/>
<rect key="frame" x="0.0" y="0.0" width="152" height="280"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oag-iN-lAn">
<rect key="frame" x="0.0" y="0.0" width="152" height="28"/>
Expand Down Expand Up @@ -985,10 +985,18 @@
<action selector="openWeb:" destination="VqS-l1-kwe" eventType="touchUpInside" id="AUt-Af-7f1"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rJk-dh-q7U">
<rect key="frame" x="0.0" y="252" width="152" height="28"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<state key="normal" title="Corrupt Envelope"/>
<connections>
<action selector="corruptEnvelope:" destination="VqS-l1-kwe" eventType="touchUpInside" id="cxk-nv-H4i"/>
</connections>
</button>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" translatesAutoresizingMaskIntoConstraints="NO" id="ULj-Tl-kYs">
<rect key="frame" x="152" y="0.0" width="152" height="252"/>
<rect key="frame" x="152" y="0.0" width="152" height="280"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="weS-d7-IY1">
<rect key="frame" x="0.0" y="0.0" width="152" height="28"/>
Expand All @@ -999,23 +1007,23 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ckT-1E-GWZ">
<rect key="frame" x="0.0" y="28" width="152" height="28"/>
<rect key="frame" x="0.0" y="31.5" width="152" height="28"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<state key="normal" title="Close SDK"/>
<connections>
<action selector="close:" destination="VqS-l1-kwe" eventType="touchUpInside" id="UwB-2M-pCr"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rpD-Rf-xbz">
<rect key="frame" x="0.0" y="56" width="152" height="28"/>
<rect key="frame" x="0.0" y="63" width="152" height="28"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<state key="normal" title="ANR fully blocking"/>
<connections>
<action selector="anrFullyBlocking:" destination="VqS-l1-kwe" eventType="touchUpInside" id="PLh-oH-8oF"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2e4-48-rLl">
<rect key="frame" x="0.0" y="84" width="152" height="28"/>
<rect key="frame" x="0.0" y="94.5" width="152" height="28"/>
<accessibility key="accessibilityConfiguration" identifier="anrFillingRunLoopExtra"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<state key="normal" title="ANR filling run loop"/>
Expand All @@ -1024,7 +1032,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6Jr-19-VhC">
<rect key="frame" x="0.0" y="112" width="152" height="28"/>
<rect key="frame" x="0.0" y="126" width="152" height="28"/>
<accessibility key="accessibilityConfiguration" identifier="anrFillingRunLoopExtra"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<state key="normal" title="Pasteboard Contents"/>
Expand All @@ -1033,7 +1041,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="F0l-xf-cQd">
<rect key="frame" x="0.0" y="140" width="152" height="28"/>
<rect key="frame" x="0.0" y="157.5" width="152" height="28"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Start 100 threads"/>
Expand All @@ -1042,7 +1050,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Evt-B9-zEC">
<rect key="frame" x="0.0" y="168" width="152" height="28"/>
<rect key="frame" x="0.0" y="189" width="152" height="28"/>
<accessibility key="accessibilityConfiguration" identifier="breadcrumbInfoButton"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
Expand All @@ -1052,7 +1060,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5U2-RQ-FCu">
<rect key="frame" x="0.0" y="196" width="152" height="28"/>
<rect key="frame" x="0.0" y="220.5" width="152" height="28"/>
<accessibility key="accessibilityConfiguration" identifier="TOPVCBTN"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
Expand All @@ -1062,7 +1070,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NEs-RL-K3q">
<rect key="frame" x="0.0" y="224" width="152" height="28"/>
<rect key="frame" x="0.0" y="252" width="152" height="28"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Show UI Test"/>
Expand All @@ -1075,23 +1083,23 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="omd-Rj-xhq">
<rect key="frame" x="0.0" y="252" width="304" height="149"/>
<rect key="frame" x="0.0" y="280" width="304" height="121"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eMF-4u-JGE">
<rect key="frame" x="8" y="32" width="288" height="31"/>
<rect key="frame" x="8" y="32" width="288" height="21.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Frames" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xua-qE-dXN" userLabel="frames">
<rect key="frame" x="8" y="63" width="288" height="31"/>
<rect key="frame" x="8" y="53.5" width="288" height="22"/>
<accessibility key="accessibilityConfiguration" identifier="framesStatsLabel"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Last breadcrumb" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4M5-qM-BM9" userLabel="breadcrumb">
<rect key="frame" x="8" y="94" width="288" height="31"/>
<rect key="frame" x="8" y="75.5" width="288" height="21.5"/>
<accessibility key="accessibilityConfiguration" identifier="breadcrumbLabel"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
Expand Down Expand Up @@ -1279,7 +1287,7 @@
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemGray5Color">
<color red="0.8980392157" green="0.8980392157" blue="0.91764705879999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.89803921568627454" green="0.89803921568627454" blue="0.91764705882352937" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
24 changes: 24 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/ExtraViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,30 @@ class ExtraViewController: UIViewController {
}
}

@IBAction func corruptEnvelope(_ sender: UIButton) {
guard let dsnHash = SentrySDK.options?.parsedDsn?.getHash() else {
fatalError("dsnHash can not be nil!")
}

guard let cachePath = SentrySDK.options?.cacheDirectoryPath else {
fatalError("cachePath can not be nil!")
}

let envelopePath = "\(cachePath)/io.sentry/\(dsnHash)/envelopes/corrupted-envelope.json"

let corruptedEnvelopeData = """
{"event_id":"1990b5bc31904b7395fd07feb72daf1c","sdk":{"name":"sentry.cocoa","version":"8.33.0"}}
{"type":"test","length":50}
""".data(using: .utf8)!

do {
try corruptedEnvelopeData.write(to: URL(fileURLWithPath: envelopePath))
print("Corrupted envelope saved to: " + envelopePath)
} catch {
fatalError("Error while writing corrupted envelope to: " + envelopePath)
}
}

private func calcPi() -> Double {
var denominator = 1.0
var pi = 0.0
Expand Down

0 comments on commit 8ee95e2

Please sign in to comment.