Skip to content

Commit

Permalink
tests(maze): Rework tests to ensure foreground/rotation set before event
Browse files Browse the repository at this point in the history
Adding wait time to the default event runner broke the foreground tests,
as the event might fire before the home button is pressed

Restores the rotation tests though leaving the preflight check since
the test does not validate post-launch rotation.
  • Loading branch information
kattrali committed Sep 17, 2018
1 parent 4958115 commit 49036c4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 58 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import java.lang.Runnable;

public class CXXBackgroundCrashScenario extends Scenario {
public class CXXDelayedCrashScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("entrypoint");
Expand All @@ -22,7 +22,7 @@ public class CXXBackgroundCrashScenario extends Scenario {
private boolean didActivate = false;
private Handler handler = new Handler();

public CXXBackgroundCrashScenario(@NonNull Configuration config, @NonNull Context context) {
public CXXDelayedCrashScenario(@NonNull Configuration config, @NonNull Context context) {
super(config, context);
config.setAutoCaptureSessions(false);
}
Expand All @@ -44,9 +44,5 @@ public void run() {
activate(405);
}
}, 6000);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
this.getContext().startActivity(intent);
}
}
33 changes: 31 additions & 2 deletions features/native_event_tracking.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: Synchronizing app/device metadata in the native layer
And the event "unhandled" is false

Scenario: Capture foreground state while in the background
When I run "CXXBackgroundNotifyScenario"
When I run "CXXDelayedNotifyScenario" and press the home button
And I wait a bit
Then the request payload contains a completed native report
And the event "app.inForeground" is false
Expand All @@ -31,7 +31,7 @@ Feature: Synchronizing app/device metadata in the native layer
And the event "unhandled" is true

Scenario: Capture foreground state while in a background crash
When I run "CXXBackgroundCrashScenario"
When I run "CXXDelayedCrashScenario" and press the home button
And I wait a bit
And I configure the app to run in the "non-crashy" state
And I relaunch the app
Expand All @@ -41,3 +41,32 @@ Feature: Synchronizing app/device metadata in the native layer
And the event "app.duration" is greater than 0
And the event "context" string is empty
And the event "unhandled" is true

Scenario Outline: Capture rotation and notify in C
When I run "CXXDelayedNotifyScenario" in "<mode>" orientation
And I wait a bit
Then the request payload contains a completed native report
And the event "device.orientation" equals "<orientation>"

Examples:
| mode | orientation |
| landscape-left | landscape |
| landscape-right | landscape |
| upside-down | portrait |
| portrait | portrait |

Scenario Outline: Capture rotation and crash in C
When I run "CXXDelayedCrashScenario" in "<mode>" orientation
And I wait a bit
And I configure the app to run in the "non-crashy" state
And I relaunch the app
Then the request payload contains a completed native report
And the event "device.orientation" equals "<orientation>"

Examples:
| mode | orientation |
| landscape-left | landscape |
| landscape-right | landscape |
| upside-down | portrait |
| portrait | portrait |

10 changes: 8 additions & 2 deletions features/steps/build_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
step("I wait for #{wait_time} seconds")
end

When(/^I run "([^"]+)"$/) do |event_type|
When(/^I run "([^"]+)"( and press the home button)?$/) do |event_type, pressed_home|
step("I run \"#{event_type}\" against \"#{ENV['ANDROID_EMULATOR']}\"")
step("I press the home button") if pressed_home
step("I wait for #{wait_time} seconds")
end

When(/^I run "([^"]+)" in "([^"]+)" orientation$/) do |event_type, orientation|
step("I rotate the device to \"#{orientation}\"")
step("I run \"#{event_type}\"")
end

When(/^I run "([^"]+)" against "([^"]+)"$/) do |event_type, emulator|
Expand All @@ -17,7 +24,6 @@
And I set environment variable "BUGSNAG_API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I set environment variable "EVENT_TYPE" to "#{event_type}"
And I start the "com.bugsnag.android.mazerunner" Android app using the "com.bugsnag.android.mazerunner.MainActivity" activity
And I wait for #{wait_time} seconds
}
end

Expand Down

0 comments on commit 49036c4

Please sign in to comment.