Update Test Dependency version (#4405)

* Update Version and Unit Test

* fix failing tests

* update robolectric
This commit is contained in:
Madhur Gupta 2021-05-10 12:52:56 +05:30 committed by GitHub
parent 117a7805ad
commit 2f4c30416d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 122 additions and 82 deletions

View file

@ -1,6 +1,7 @@
package fr.free.nrw.commons.navtab
import android.content.Context
import android.os.Looper
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import fr.free.nrw.commons.TestCommonsApplication
@ -12,10 +13,13 @@ import org.junit.runner.RunWith
import org.robolectric.Robolectric
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.Shadows
import org.robolectric.annotation.Config
import org.robolectric.annotation.LooperMode
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [21], application = TestCommonsApplication::class)
@LooperMode(LooperMode.Mode.PAUSED)
class MoreBottomSheetFragmentUnitTests {
private lateinit var fragment: MoreBottomSheetFragment
@ -45,48 +49,56 @@ class MoreBottomSheetFragmentUnitTests {
@Test
@Throws(Exception::class)
fun testOnAttach() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onAttach(context)
}
@Test
@Throws(Exception::class)
fun testOnLogoutClicked() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onLogoutClicked()
}
@Test
@Throws(Exception::class)
fun testOnFeedbackClicked() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onFeedbackClicked()
}
@Test
@Throws(Exception::class)
fun testOnAboutClicked() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onAboutClicked()
}
@Test
@Throws(Exception::class)
fun testOnTutorialClicked() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onTutorialClicked()
}
@Test
@Throws(Exception::class)
fun testOnSettingsClicked() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onSettingsClicked()
}
@Test
@Throws(Exception::class)
fun testOnProfileClicked() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onProfileClicked()
}
@Test
@Throws(Exception::class)
fun testOnPeerReviewClicked() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onPeerReviewClicked()
}

View file

@ -1,6 +1,7 @@
package fr.free.nrw.commons.navtab
import android.content.Context
import android.os.Looper
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import fr.free.nrw.commons.TestCommonsApplication
@ -12,10 +13,13 @@ import org.junit.runner.RunWith
import org.robolectric.Robolectric
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.Shadows
import org.robolectric.annotation.Config
import org.robolectric.annotation.LooperMode
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [21], application = TestCommonsApplication::class)
@LooperMode(LooperMode.Mode.PAUSED)
class MoreBottomSheetLoggedOutFragmentUnitTests {
private lateinit var fragment: MoreBottomSheetLoggedOutFragment
@ -45,30 +49,35 @@ class MoreBottomSheetLoggedOutFragmentUnitTests {
@Test
@Throws(Exception::class)
fun testOnTutorialClicked() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onTutorialClicked()
}
@Test
@Throws(Exception::class)
fun testOnSettingsClicked() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onSettingsClicked()
}
@Test
@Throws(Exception::class)
fun testOnAboutClicked() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onAboutClicked()
}
@Test
@Throws(Exception::class)
fun testOnFeedbackClicked() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onFeedbackClicked()
}
@Test
@Throws(Exception::class)
fun testOnLogoutClicked() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.onLogoutClicked()
}