This commit is contained in:
Milos Kozak 2019-12-12 00:23:02 +01:00
parent 5ba54f8cdc
commit 44e3a15d47

View file

@ -12,9 +12,9 @@ import androidx.test.espresso.action.ViewActions.scrollTo
import androidx.test.espresso.matcher.ViewMatchers.* import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest import androidx.test.filters.LargeTest
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.ActivityTestRule import androidx.test.rule.ActivityTestRule
import androidx.test.rule.GrantPermissionRule import androidx.test.rule.GrantPermissionRule
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
import info.nightscout.androidaps.setupwizard.SetupWizardActivity import info.nightscout.androidaps.setupwizard.SetupWizardActivity
import info.nightscout.androidaps.utils.SP import info.nightscout.androidaps.utils.SP
import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.allOf
@ -32,11 +32,6 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class)
class SetupWizardActivityTest { class SetupWizardActivityTest {
/**
* wait below 8000ms was sometimes not enough for reset all permissions on circle ci emulator
*/
private val DELAY_FOR_COMMAND_EXECUTION = 8000L
@Rule @Rule
@JvmField @JvmField
var mActivityTestRule = ActivityTestRule(SetupWizardActivity::class.java) var mActivityTestRule = ActivityTestRule(SetupWizardActivity::class.java)
@ -50,16 +45,23 @@ class SetupWizardActivityTest {
android.Manifest.permission.WRITE_EXTERNAL_STORAGE android.Manifest.permission.WRITE_EXTERNAL_STORAGE
) )
fun resetAllPermission() { // permissions handling only available since android marshmallow
InstrumentationRegistry.getInstrumentation().uiAutomation.executeShellCommand("pm reset-permissions")
SystemClock.sleep(DELAY_FOR_COMMAND_EXECUTION)
}
@Before @Before
fun clear() { fun clear() {
//resetAllPermission()
SP.clear() SP.clear()
} }
/*
To run from command line
gradlew connectedFullDebugAndroidTest
do not run when your production phone is connected !!!
do this before for running in emulator
adb shell settings put global window_animation_scale 0 &
adb shell settings put global transition_animation_scale 0 &
adb shell settings put global animator_duration_scale 0 &
*/
@Test @Test
fun setupWizardActivityTest() { fun setupWizardActivityTest() {
@ -145,6 +147,7 @@ class SetupWizardActivityTest {
askButton.perform(scrollTo(), click()) askButton.perform(scrollTo(), click())
onView(allOf(withId(R.id.ok), isDisplayed())).perform(click()) onView(allOf(withId(R.id.ok), isDisplayed())).perform(click())
onView(Matchers.allOf(withText("OK"), isDisplayed())).perform(click()) onView(Matchers.allOf(withText("OK"), isDisplayed())).perform(click())
while (ProfileFunctions.getInstance().profile == null) SystemClock.sleep(100)
onView(withId(R.id.next_button)).perform(click()) onView(withId(R.id.next_button)).perform(click())
} }
// Pump // Pump