Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Oct 18, 2023
1 parent 85d3413 commit beb3ae0
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.hamcrest.CoreMatchers.containsString
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.notNullValue
import org.hamcrest.CoreMatchers.nullValue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -27,7 +29,9 @@ import org.odk.collect.android.support.CollectHelpers
import org.odk.collect.android.version.VersionInformation
import org.odk.collect.androidtest.ActivityScenarioLauncherRule
import org.odk.collect.androidtest.RecordedIntentsRule
import org.odk.collect.material.MaterialProgressDialogFragment
import org.odk.collect.strings.localization.getLocalizedString
import org.odk.collect.testshared.RobolectricHelpers

@RunWith(AndroidJUnit4::class)
class FirstLaunchActivityTest {
Expand Down Expand Up @@ -92,4 +96,25 @@ class FirstLaunchActivityTest {
).perform(scrollTo()).check(matches(isDisplayed()))
}
}

@Test
fun `Adding demo project displays a progress dialog`() {
val scenario = launcherRule.launch(FirstLaunchActivity::class.java)
scenario.onActivity {
val dialogClass = MaterialProgressDialogFragment::class.java
assertThat(RobolectricHelpers.getFragmentByClass(it.supportFragmentManager, dialogClass), nullValue())

onView(
withText(
containsString(
ApplicationProvider.getApplicationContext<Collect>().getLocalizedString(
org.odk.collect.strings.R.string.try_demo
)
)
)
).perform(scrollTo()).perform(click())

assertThat(RobolectricHelpers.getFragmentByClass(it.supportFragmentManager, dialogClass), notNullValue())
}
}
}

0 comments on commit beb3ae0

Please sign in to comment.