-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from bugsnag/stop-sessions
Add stopSession() and resumeSession() to public API
- Loading branch information
Showing
19 changed files
with
303 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule bugsnag-android
updated
35 files
Submodule bugsnag-cocoa
updated
76 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Feature: Stopping and resuming sessions | ||
|
||
Scenario: When a session is stopped the error has no session information | ||
When I run the game in the "StoppedSession" state | ||
Then I should receive 2 requests | ||
And the request 0 is valid for the session tracking API | ||
And the request 1 is valid for the error reporting API | ||
And the payload field "events.0.session" is null for request 1 | ||
|
||
Scenario: When a session is resumed the error uses the previous session information | ||
When I run the game in the "ResumedSession" state | ||
Then I should receive 3 requests | ||
And the request 0 is valid for the session tracking API | ||
And the request 1 is valid for the error reporting API | ||
And the request 2 is valid for the error reporting API | ||
And the payload field "events.0.session.id" of request 1 equals the payload field "events.0.session.id" of request 2 | ||
And the payload field "events.0.session.startedAt" of request 1 equals the payload field "events.0.session.startedAt" of request 2 | ||
And the events in requests "1,2" match one of: | ||
| message | handled | unhandled | | ||
| First Error | 1 | 0 | | ||
| Second Error | 2 | 0 | | ||
|
||
Scenario: When a new session is started the error uses different session information | ||
When I run the game in the "NewSession" state | ||
Then I should receive 4 requests | ||
And the request 0 is valid for the session tracking API | ||
And the request 1 is valid for the session tracking API | ||
And the request 2 is valid for the error reporting API | ||
And the request 3 is valid for the error reporting API | ||
And the payload field "events.0.session.events.handled" equals 1 for request 2 | ||
And the payload field "events.0.session.events.handled" equals 1 for request 3 | ||
And the payload field "events.0.session.id" of request 2 does not equal the payload field "events.0.session.id" of request 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using NUnit.Framework; | ||
using System.Linq; | ||
using System.Threading; | ||
using UnityEngine; | ||
|
||
namespace BugsnagUnity.Payload.Tests | ||
{ | ||
[TestFixture] | ||
class SessionTrackerTests | ||
{ | ||
|
||
public SessionTracker Tracker { get; set; } | ||
|
||
public SessionTrackerTests() | ||
{ | ||
Client client = new Client(new NativeClient(new Configuration("api-key"))); | ||
Tracker = new SessionTracker(client); | ||
Assert.IsNotNull(Tracker); | ||
} | ||
|
||
/** | ||
* Verifies that a session can be resumed after it is stopped | ||
*/ | ||
[Test] | ||
public void ResumeFromStoppedSession() { | ||
Tracker.StartSession(); | ||
var originalSession = Tracker.CurrentSession; | ||
Assert.IsNotNull(originalSession); | ||
|
||
Tracker.StopSession(); | ||
Assert.IsNull(Tracker.CurrentSession); | ||
|
||
Assert.IsTrue(Tracker.ResumeSession()); | ||
Assert.AreEqual(originalSession, Tracker.CurrentSession); | ||
} | ||
|
||
/** | ||
* Verifies that the previous session is resumed when calling SessionTracker.ResumeSession | ||
*/ | ||
[Test] | ||
public void ResumeWithNoStoppedSession() { | ||
Tracker.StartSession(); | ||
Tracker.StopSession(); | ||
Assert.IsTrue(Tracker.ResumeSession()); | ||
Assert.IsFalse(Tracker.ResumeSession()); | ||
} | ||
|
||
/** | ||
* Verifies that a new session can be created after the previous one is stopped | ||
*/ | ||
[Test] | ||
public void StartNewAfterStoppedSession() { | ||
Tracker.StartSession(); | ||
var originalSession = Tracker.CurrentSession; | ||
|
||
Tracker.StopSession(); | ||
Tracker.StartSession(); | ||
Assert.AreNotEqual(originalSession, Tracker.CurrentSession); | ||
} | ||
|
||
/** | ||
* Verifies that calling SessionTracker.ResumeSession multiple times only starts one session | ||
*/ | ||
[Test] | ||
public void MultipleResumesHaveNoEffect() { | ||
Tracker.StartSession(); | ||
var original = Tracker.CurrentSession; | ||
Tracker.StopSession(); | ||
|
||
Assert.IsTrue(Tracker.ResumeSession()); | ||
Assert.AreEqual(original, Tracker.CurrentSession); | ||
|
||
Assert.IsFalse(Tracker.ResumeSession()); | ||
Assert.AreEqual(original, Tracker.CurrentSession); | ||
} | ||
|
||
/** | ||
* Verifies that calling SessionTracker.StopSession multiple times only stops one session | ||
*/ | ||
[Test] | ||
public void MultipleStopsHaveNoEffect() { | ||
Tracker.StartSession(); | ||
Assert.IsNotNull(Tracker.CurrentSession); | ||
|
||
Tracker.StopSession(); | ||
Assert.IsNull(Tracker.CurrentSession); | ||
|
||
Tracker.StopSession(); | ||
Assert.IsNull(Tracker.CurrentSession); | ||
} | ||
} | ||
} |
Oops, something went wrong.