-
-
Notifications
You must be signed in to change notification settings - Fork 267
Add tests for the Android and iOS plugin #1587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
8cb2613
add first test to android
denrase 57a189e
update remaining options for android
denrase 557867b
test update of options in ios/macos plugin
denrase 0e644ed
change provisioning profile
denrase 286e8f3
run native tests un integration test workflow
denrase ddc9041
new detekt baseline
denrase 7d2c460
fix some lint issues
denrase d905ab7
fix klint issue
denrase 686e7d6
remove trailing commas
denrase 787dfac
update baseline
denrase a590378
set junit version directly
denrase c357792
fix swiftlint issues
denrase a2f07a3
fix klint issues
denrase 3cc4682
remove trailing commas
denrase 337e279
comment out in action
denrase 2b774a1
remove comments
denrase a3cdb7a
Merge branch 'main' into denrase/test-native-plugin-init
denrase dbb1454
run ios native test
denrase cd604d4
try native test only
denrase fb9c99d
update wd to start from root dir
denrase c858af8
run on created device
denrase 7fcb9e9
run on sim
denrase 6dc9e6c
use id to start test
denrase a44bfcc
run on 16.4 target
denrase 424a77b
lower deployment target of tests
denrase d2434bf
build ios app
denrase edf9110
handle provision profile issue
denrase 8d4afdb
run build before launching sim
denrase 1bff064
just run pod install
denrase 179656e
run native test on android device
denrase e8856a1
check why gradlew is not present (wrong folder?)
denrase 83231b6
init gradle wrapper
denrase 2c1495a
run gradle wrapper init in sep. step
denrase acdd4a4
build apk
denrase a505327
rename action
denrase b2cdeeb
Merge branch 'main' into denrase/test-native-plugin-init
denrase 6e5aba2
provide auth token as env
denrase ef5516a
uncomment other tests to test integration test
denrase 0fd5be0
disable e2e test
denrase 89b82fb
disable e2e test & enable native tests
denrase 170763a
add alias in macos folder
denrase c2d8736
add detekt rule
denrase 671d550
fix macos example target
denrase fcecded
provide device id
denrase 4905b17
run integration tests before native tests
denrase 1a84ab4
remove lines
denrase 62aa008
disable integration test
denrase 430038b
Merge branch 'main' into denrase/test-native-plugin-init
denrase da19bc2
comment in e2e test
denrase 2c11a95
diable e2e test
denrase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -83,6 +83,18 @@ jobs: | |
profile: Nexus 6 | ||
script: flutter test integration_test/integration_test.dart --verbose | ||
|
||
- name: launch android emulator & run android native test | ||
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected] | ||
with: | ||
working-directory: ./flutter/example/android | ||
api-level: 21 | ||
force-avd-creation: false | ||
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | ||
disable-animations: true | ||
arch: x86_64 | ||
profile: Nexus 6 | ||
script: ./gradlew testDebugUnitTest | ||
|
||
test-ios: | ||
runs-on: macos-13 | ||
timeout-minutes: 30 | ||
|
@@ -113,5 +125,9 @@ jobs: | |
simulator_id=$(xcrun simctl create sentryPhone com.apple.CoreSimulator.SimDeviceType.iPhone-14 com.apple.CoreSimulator.SimRuntime.iOS-16-2) | ||
xcrun simctl boot ${simulator_id} | ||
|
||
- name: run ios integration test | ||
run: flutter test integration_test/integration_test.dart --verbose | ||
# - name: run ios integration test | ||
# run: flutter test integration_test/integration_test.dart --verbose | ||
|
||
- name: run native test | ||
working-directory: ./flutter/example/ios | ||
run: xcodebuild test -workspace Runner.xcworkspace -scheme Runner -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 14' |
This file contains hidden or 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
129 changes: 129 additions & 0 deletions
129
flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutter.kt
This file contains hidden or 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,129 @@ | ||
package io.sentry.flutter | ||
|
||
import io.sentry.SentryLevel | ||
import io.sentry.android.core.BuildConfig | ||
import io.sentry.android.core.SentryAndroidOptions | ||
import io.sentry.protocol.SdkVersion | ||
import java.util.Locale | ||
|
||
class SentryFlutter( | ||
private val androidSdk: String, | ||
private val nativeSdk: String | ||
) { | ||
|
||
var autoPerformanceTracingEnabled = false | ||
|
||
fun updateOptions(options: SentryAndroidOptions, data: Map<String, Any>) { | ||
data.getIfNotNull<String>("dsn") { | ||
options.dsn = it | ||
} | ||
data.getIfNotNull<Boolean>("debug") { | ||
options.isDebug = it | ||
} | ||
data.getIfNotNull<String>("environment") { | ||
options.environment = it | ||
} | ||
data.getIfNotNull<String>("release") { | ||
options.release = it | ||
} | ||
data.getIfNotNull<String>("dist") { | ||
options.dist = it | ||
} | ||
data.getIfNotNull<Boolean>("enableAutoSessionTracking") { | ||
options.isEnableAutoSessionTracking = it | ||
} | ||
data.getIfNotNull<Long>("autoSessionTrackingIntervalMillis") { | ||
options.sessionTrackingIntervalMillis = it | ||
} | ||
data.getIfNotNull<Long>("anrTimeoutIntervalMillis") { | ||
options.anrTimeoutIntervalMillis = it | ||
} | ||
data.getIfNotNull<Boolean>("attachThreads") { | ||
options.isAttachThreads = it | ||
} | ||
data.getIfNotNull<Boolean>("attachStacktrace") { | ||
options.isAttachStacktrace = it | ||
} | ||
data.getIfNotNull<Boolean>("enableAutoNativeBreadcrumbs") { | ||
options.isEnableActivityLifecycleBreadcrumbs = it | ||
options.isEnableAppLifecycleBreadcrumbs = it | ||
options.isEnableSystemEventBreadcrumbs = it | ||
options.isEnableAppComponentBreadcrumbs = it | ||
options.isEnableUserInteractionBreadcrumbs = it | ||
} | ||
data.getIfNotNull<Int>("maxBreadcrumbs") { | ||
options.maxBreadcrumbs = it | ||
} | ||
data.getIfNotNull<Int>("maxCacheItems") { | ||
options.maxCacheItems = it | ||
} | ||
data.getIfNotNull<String>("diagnosticLevel") { | ||
if (options.isDebug) { | ||
val sentryLevel = SentryLevel.valueOf(it.toUpperCase(Locale.ROOT)) | ||
options.setDiagnosticLevel(sentryLevel) | ||
} | ||
} | ||
data.getIfNotNull<Boolean>("anrEnabled") { | ||
options.isAnrEnabled = it | ||
} | ||
data.getIfNotNull<Boolean>("sendDefaultPii") { | ||
options.isSendDefaultPii = it | ||
} | ||
data.getIfNotNull<Boolean>("enableNdkScopeSync") { | ||
options.isEnableScopeSync = it | ||
} | ||
data.getIfNotNull<String>("proguardUuid") { | ||
options.proguardUuid = it | ||
} | ||
|
||
val nativeCrashHandling = (data["enableNativeCrashHandling"] as? Boolean) ?: true | ||
// nativeCrashHandling has priority over anrEnabled | ||
if (!nativeCrashHandling) { | ||
options.isEnableUncaughtExceptionHandler = false | ||
options.isAnrEnabled = false | ||
// if split symbols are enabled, we need Ndk integration so we can't really offer the option | ||
// to turn it off | ||
// options.isEnableNdk = false | ||
} | ||
|
||
data.getIfNotNull<Boolean>("enableAutoPerformanceTracing") { enableAutoPerformanceTracing -> | ||
if (enableAutoPerformanceTracing) { | ||
autoPerformanceTracingEnabled = true | ||
} | ||
} | ||
|
||
data.getIfNotNull<Boolean>("sendClientReports") { | ||
options.isSendClientReports = it | ||
} | ||
|
||
data.getIfNotNull<Long>("maxAttachmentSize") { | ||
options.maxAttachmentSize = it | ||
} | ||
|
||
var sdkVersion = options.sdkVersion | ||
if (sdkVersion == null) { | ||
sdkVersion = SdkVersion(androidSdk, BuildConfig.VERSION_NAME) | ||
} else { | ||
sdkVersion.name = androidSdk | ||
} | ||
|
||
options.sdkVersion = sdkVersion | ||
options.sentryClientName = "$androidSdk/${BuildConfig.VERSION_NAME}" | ||
options.nativeSdkName = nativeSdk | ||
|
||
data.getIfNotNull<Int>("connectionTimeoutMillis") { | ||
options.connectionTimeoutMillis = it | ||
} | ||
data.getIfNotNull<Int>("readTimeoutMillis") { | ||
options.readTimeoutMillis = it | ||
} | ||
} | ||
} | ||
|
||
// Call the `completion` closure if cast to map value with `key` and type `T` is successful. | ||
@Suppress("UNCHECKED_CAST") | ||
private fun <T> Map<String, Any>.getIfNotNull(key: String, callback: (T) -> Unit) { | ||
(get(key) as? T)?.let { | ||
callback(it) | ||
} | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.