2021-04-09 14:15:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 Proton Technologies AG
|
|
|
|
*
|
|
|
|
* This file is part of ProtonMail.
|
|
|
|
*
|
|
|
|
* ProtonMail is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* ProtonMail is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
|
|
|
*/
|
|
|
|
|
2021-04-12 07:34:11 +00:00
|
|
|
package ch.protonmail.android
|
2021-04-09 14:15:31 +00:00
|
|
|
|
|
|
|
import ch.protonmail.android.di.BaseUrl
|
|
|
|
import dagger.hilt.android.testing.HiltAndroidRule
|
|
|
|
import dagger.hilt.android.testing.HiltAndroidTest
|
2021-04-12 07:34:11 +00:00
|
|
|
import org.assertj.core.api.Assertions.assertThat
|
2021-04-09 14:15:31 +00:00
|
|
|
import org.junit.Rule
|
|
|
|
import javax.inject.Inject
|
|
|
|
import kotlin.test.BeforeTest
|
|
|
|
import kotlin.test.Test
|
2021-04-12 07:34:11 +00:00
|
|
|
import kotlin.test.assertEquals
|
2021-04-09 14:15:31 +00:00
|
|
|
|
|
|
|
@HiltAndroidTest
|
2021-04-12 07:34:11 +00:00
|
|
|
class ExampleCustomInjectionTest {
|
2021-04-09 14:15:31 +00:00
|
|
|
|
2021-04-12 07:34:11 +00:00
|
|
|
@get:Rule(order = 0) // Ensures that the Hilt component is initialized before running the ActivityScenarioRule
|
2021-04-09 14:15:31 +00:00
|
|
|
var hiltRule = HiltAndroidRule(this)
|
|
|
|
|
2021-04-12 07:34:11 +00:00
|
|
|
// @get:Rule(order = 1)
|
|
|
|
// val activityRule = activityScenarioRule<SplashActivity>()
|
2021-04-09 14:15:31 +00:00
|
|
|
|
|
|
|
@Inject
|
|
|
|
@BaseUrl
|
|
|
|
lateinit var baseUrl: String
|
|
|
|
|
|
|
|
@BeforeTest
|
|
|
|
fun init() {
|
|
|
|
hiltRule.inject()
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2021-04-12 07:34:11 +00:00
|
|
|
fun verifyBaseUrl() {
|
2021-04-09 14:15:31 +00:00
|
|
|
|
2021-04-12 07:34:11 +00:00
|
|
|
assertThat(baseUrl).isNotNull
|
|
|
|
assertEquals("http://localhost:8080/", baseUrl)
|
2021-04-09 14:15:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|