Grant WRITE_EXTERNAL_STORAGE permission for UI tests

The absence of this was causing the tests to fail on Firebase.
This commit is contained in:
William Brawner 2021-02-20 22:23:58 -07:00
parent 67bf1626a0
commit b056e779e0
2 changed files with 7 additions and 1 deletions

View file

@ -44,6 +44,7 @@ android {
versionCode 32 versionCode 32
versionName "0.8.10" versionName "0.8.10"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'
buildConfigField "boolean", "ENABLE_CUSTOM_CSS", "false" buildConfigField "boolean", "ENABLE_CUSTOM_CSS", "false"
} }
signingConfigs { signingConfigs {

View file

@ -1,5 +1,6 @@
package com.wbrawner.simplemarkdown package com.wbrawner.simplemarkdown
import android.Manifest.permission.WRITE_EXTERNAL_STORAGE
import android.app.Activity.RESULT_OK import android.app.Activity.RESULT_OK
import android.app.Instrumentation import android.app.Instrumentation
import android.content.Context import android.content.Context
@ -22,6 +23,7 @@ import androidx.test.espresso.web.webdriver.DriverAtoms.findElement
import androidx.test.espresso.web.webdriver.DriverAtoms.getText import androidx.test.espresso.web.webdriver.DriverAtoms.getText
import androidx.test.espresso.web.webdriver.Locator import androidx.test.espresso.web.webdriver.Locator
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import androidx.test.rule.GrantPermissionRule
import com.wbrawner.simplemarkdown.view.activity.MainActivity import com.wbrawner.simplemarkdown.view.activity.MainActivity
import org.hamcrest.Matchers.containsString import org.hamcrest.Matchers.containsString
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
@ -36,6 +38,9 @@ class MarkdownTests {
@get:Rule @get:Rule
var activityRule = IntentsTestRule(MainActivity::class.java, false, false) var activityRule = IntentsTestRule(MainActivity::class.java, false, false)
@get:Rule
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(WRITE_EXTERNAL_STORAGE)
lateinit var file: File lateinit var file: File
@Before @Before
@ -66,7 +71,7 @@ class MarkdownTests {
} }
@Test @Test
fun newMarkdownTest() { fun newMarkdownTest() {
onView(withId(R.id.markdown_edit)) onView(withId(R.id.markdown_edit))
.perform(typeText("# UI Testing\n\nThe quick brown fox jumped over the lazy dog.")) .perform(typeText("# UI Testing\n\nThe quick brown fox jumped over the lazy dog."))
openActionBarOverflowOrOptionsMenu(getApplicationContext()) openActionBarOverflowOrOptionsMenu(getApplicationContext())