0
0
mirror of https://github.com/mediathekview/zapp.git synced 2024-09-20 12:22:15 +02:00

Instrumentation test about fragments

This commit is contained in:
Christine Coenen 2022-04-22 14:36:32 +02:00
parent 87291953b1
commit ebe2fe9d12
5 changed files with 98 additions and 7 deletions

View File

@ -76,29 +76,37 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
def fragment_version = '1.4.1'
// kotlin
implementation 'androidx.core:core-ktx:1.7.0'
// tests
debugImplementation 'androidx.test:core:1.4.0'
debugImplementation 'androidx.fragment:fragment-testing:1.4.1'
def androix_test_version = '1.4.0'
// device tests
def espresso_version = '3.4.0'
debugImplementation "androidx.fragment:fragment-testing:$fragment_version"
androidTestImplementation "androidx.test:core-ktx:$androix_test_version"
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
androidTestImplementation("androidx.test.espresso:espresso-core:$espresso_version") {
exclude group: 'org.checkerframework', module: 'checker'
}
androidTestImplementation("androidx.test.espresso:espresso-contrib:$espresso_version") {
exclude group: 'org.checkerframework', module: 'checker'
}
// unit tests
testImplementation 'androidx.test.ext:junit-ktx:1.1.3'
testImplementation 'androidx.test:core-ktx:1.4.0'
testImplementation 'junit:junit:4.13.2'
testImplementation "androidx.test:core-ktx:$androix_test_version"
testImplementation 'org.robolectric:robolectric:4.6.1'
testImplementation 'org.mockito.kotlin:mockito-kotlin:3.2.0'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0'
// support
implementation 'androidx.fragment:fragment-ktx:1.4.1'
implementation "androidx.fragment:fragment-ktx:$fragment_version"
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"

View File

@ -0,0 +1,26 @@
package de.christinecoenen.code.zapp.app.about.ui
import android.content.pm.ActivityInfo
import androidx.fragment.app.testing.launchFragmentInContainer
import androidx.test.ext.junit.runners.AndroidJUnit4
import de.christinecoenen.code.zapp.R
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class AboutFragmentTest {
@Test
fun testRecreation() {
val scenario = launchFragmentInContainer<AboutFragment>(
themeResId = R.style.AppTheme
)
// landscape
scenario.onFragment {
it.activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
}
scenario.recreate()
}
}

View File

@ -0,0 +1,26 @@
package de.christinecoenen.code.zapp.app.about.ui
import android.content.pm.ActivityInfo
import androidx.fragment.app.testing.launchFragmentInContainer
import androidx.test.ext.junit.runners.AndroidJUnit4
import de.christinecoenen.code.zapp.R
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class ChangelogFragmentTest {
@Test
fun testRecreation() {
val scenario = launchFragmentInContainer<ChangelogFragment>(
themeResId = R.style.AppTheme
)
// landscape
scenario.onFragment {
it.activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
}
scenario.recreate()
}
}

View File

@ -0,0 +1,26 @@
package de.christinecoenen.code.zapp.app.about.ui
import android.content.pm.ActivityInfo
import androidx.fragment.app.testing.launchFragmentInContainer
import androidx.test.ext.junit.runners.AndroidJUnit4
import de.christinecoenen.code.zapp.R
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class FaqFragmentTest {
@Test
fun testRecreation() {
val scenario = launchFragmentInContainer<FaqFragment>(
themeResId = R.style.AppTheme
)
// landscape
scenario.onFragment {
it.activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
}
scenario.recreate()
}
}

View File

@ -3,8 +3,13 @@ package de.christinecoenen.code.zapp.app.app.livestream.ui.detail
import android.app.Activity
import android.content.pm.ActivityInfo
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso
import androidx.test.espresso.ViewAssertion
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import de.christinecoenen.code.zapp.R
import de.christinecoenen.code.zapp.app.livestream.ui.detail.ChannelPlayerActivity
import org.junit.Test
import org.junit.runner.RunWith