Improve UI test setup
care for permissions and update trulesk/test-bulter
This commit is contained in:
parent
24f6344663
commit
f3738027b2
4 changed files with 22 additions and 4 deletions
|
@ -112,7 +112,9 @@ dependencies {
|
||||||
implementation 'com.github.salomonbrys.kodein:kodein:4.1.0'
|
implementation 'com.github.salomonbrys.kodein:kodein:4.1.0'
|
||||||
compileOnly 'org.glassfish:javax.annotation:3.1.1'
|
compileOnly 'org.glassfish:javax.annotation:3.1.1'
|
||||||
|
|
||||||
androidTestImplementation 'com.github.ligi:trulesk:0.28'
|
androidTestImplementation 'com.github.ligi:trulesk:0.30'
|
||||||
|
androidTestUtil 'com.linkedin.testbutler:test-butler-app:2.1.0'
|
||||||
|
|
||||||
androidTestImplementation 'androidx.test:core:1.2.0'
|
androidTestImplementation 'androidx.test:core:1.2.0'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.ligi.passandroid
|
package org.ligi.passandroid
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import androidx.test.core.app.ApplicationProvider
|
||||||
import androidx.test.espresso.Espresso.closeSoftKeyboard
|
import androidx.test.espresso.Espresso.closeSoftKeyboard
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.action.ViewActions.*
|
import androidx.test.espresso.action.ViewActions.*
|
||||||
|
@ -9,6 +11,7 @@ import androidx.test.espresso.matcher.ViewMatchers.*
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.filters.SdkSuppress
|
import androidx.test.filters.SdkSuppress
|
||||||
import com.github.salomonbrys.kodein.instance
|
import com.github.salomonbrys.kodein.instance
|
||||||
|
import com.linkedin.android.testbutler.TestButler
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -30,13 +33,15 @@ class TheBarCodeEditing {
|
||||||
private lateinit var currentPass: PassImpl
|
private lateinit var currentPass: PassImpl
|
||||||
|
|
||||||
private fun start(setupPass: (pass: PassImpl) -> Unit = {}) {
|
private fun start(setupPass: (pass: PassImpl) -> Unit = {}) {
|
||||||
|
|
||||||
TestApp.populatePassStoreWithSinglePass()
|
TestApp.populatePassStoreWithSinglePass()
|
||||||
|
|
||||||
currentPass = passStore.currentPass as PassImpl
|
currentPass = passStore.currentPass as PassImpl
|
||||||
|
|
||||||
setupPass(currentPass)
|
setupPass(currentPass)
|
||||||
|
|
||||||
|
TestButler.grantPermission(ApplicationProvider.getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||||
|
TestButler.grantPermission(ApplicationProvider.getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
|
|
||||||
rule.launchActivity(null)
|
rule.launchActivity(null)
|
||||||
closeSoftKeyboard()
|
closeSoftKeyboard()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.ligi.passandroid
|
package org.ligi.passandroid
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.Instrumentation
|
import android.app.Instrumentation
|
||||||
|
@ -11,6 +12,8 @@ import androidx.test.espresso.intent.Intents.intended
|
||||||
import androidx.test.espresso.intent.Intents.intending
|
import androidx.test.espresso.intent.Intents.intending
|
||||||
import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction
|
import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.*
|
import androidx.test.espresso.matcher.ViewMatchers.*
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import com.linkedin.android.testbutler.TestButler
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -27,6 +30,8 @@ class ThePassEditActivity {
|
||||||
@get:Rule
|
@get:Rule
|
||||||
var rule = TruleskIntentRule(PassEditActivity::class.java) {
|
var rule = TruleskIntentRule(PassEditActivity::class.java) {
|
||||||
TestApp.populatePassStoreWithSinglePass()
|
TestApp.populatePassStoreWithSinglePass()
|
||||||
|
TestButler.grantPermission(InstrumentationRegistry.getInstrumentation().targetContext, Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||||
|
TestButler.grantPermission(InstrumentationRegistry.getInstrumentation().targetContext, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package org.ligi.passandroid
|
package org.ligi.passandroid
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import androidx.test.core.app.ApplicationProvider
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import com.linkedin.android.testbutler.TestButler
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -18,7 +21,10 @@ import org.ligi.trulesk.TruleskActivityRule
|
||||||
class ThePreferenceActivity {
|
class ThePreferenceActivity {
|
||||||
|
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val rule = TruleskActivityRule(PreferenceActivity::class.java)
|
val rule = TruleskActivityRule(PreferenceActivity::class.java) {
|
||||||
|
TestButler.grantPermission(ApplicationProvider.getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||||
|
TestButler.grantPermission(ApplicationProvider.getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION)
|
||||||
|
}
|
||||||
|
|
||||||
private val androidSettings by lazy { AndroidSettings(rule.activity) }
|
private val androidSettings by lazy { AndroidSettings(rule.activity) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue