mirror of
https://github.com/home-assistant/android
synced 2024-10-01 13:53:53 +00:00
Crashlytics Setup (#33)
* Setup crashlytics * Fix possible crash when trying to retrieve external authentication
This commit is contained in:
parent
809501cc6f
commit
961ecaeb7a
|
@ -4,6 +4,7 @@ apply plugin: 'kotlin-kapt'
|
|||
apply plugin: 'com.google.firebase.appdistribution'
|
||||
apply plugin: 'com.github.triplet.play'
|
||||
apply plugin: 'de.mannodermaus.android-junit5'
|
||||
apply plugin: 'io.fabric'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
|
@ -87,6 +88,8 @@ dependencies {
|
|||
exclude group: 'org.threeten'
|
||||
}
|
||||
|
||||
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
|
||||
|
||||
testImplementation "org.spekframework.spek2:spek-dsl-jvm:$spek2Version"
|
||||
testImplementation "org.spekframework.spek2:spek-runner-junit5:$spek2Version"
|
||||
testImplementation "org.assertj:assertj-core:$assertJVersion"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.homeassistant.companion.android.webview
|
||||
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import io.homeassistant.companion.android.domain.authentication.AuthenticationUseCase
|
||||
import kotlinx.coroutines.*
|
||||
import javax.inject.Inject
|
||||
|
@ -33,7 +34,11 @@ class WebViewPresenterImpl @Inject constructor(
|
|||
|
||||
override fun onGetExternalAuth(callback: String) {
|
||||
mainScope.launch {
|
||||
view.setExternalAuth(callback, authenticationUseCase.retrieveExternalAuthentication())
|
||||
try {
|
||||
view.setExternalAuth(callback, authenticationUseCase.retrieveExternalAuthentication())
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Unable to retrieve external auth", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.net.Uri
|
|||
import io.homeassistant.companion.android.domain.authentication.AuthenticationUseCase
|
||||
import io.mockk.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.newSingleThreadContext
|
||||
import kotlinx.coroutines.test.resetMain
|
||||
import kotlinx.coroutines.test.setMain
|
||||
import org.spekframework.spek2.Spek
|
||||
|
@ -43,7 +42,7 @@ object WebViewPresenterImplSpec : Spek({
|
|||
}
|
||||
}
|
||||
|
||||
describe("on get external auth") {
|
||||
describe("on get external auth on success") {
|
||||
beforeEachTest {
|
||||
coEvery { authenticationUseCase.retrieveExternalAuthentication() } returns "{\"access_token\":\"ABCDEFGH\",\"expires_in\":1800}"
|
||||
presenter.onGetExternalAuth("externalAuthSetToken")
|
||||
|
@ -53,5 +52,18 @@ object WebViewPresenterImplSpec : Spek({
|
|||
verify { view.setExternalAuth("externalAuthSetToken", "{\"access_token\":\"ABCDEFGH\",\"expires_in\":1800}") }
|
||||
}
|
||||
}
|
||||
|
||||
describe("on get external auth on error") {
|
||||
beforeEachTest {
|
||||
coEvery { authenticationUseCase.retrieveExternalAuthentication() } throws Exception()
|
||||
presenter.onGetExternalAuth("externalAuthSetToken")
|
||||
}
|
||||
|
||||
it("should not crash") {
|
||||
coVerify {
|
||||
view wasNot Called
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
|
@ -5,12 +5,14 @@ buildscript {
|
|||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url 'https://maven.fabric.io/public' }
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.2'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath 'com.google.gms:google-services:4.3.2'
|
||||
classpath 'io.fabric.tools:gradle:1.31.2'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +20,7 @@ allprojects {
|
|||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue