mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
parent
ed572aab6f
commit
caad8644a3
2 changed files with 27 additions and 2 deletions
|
|
@ -2,6 +2,7 @@ package fr.free.nrw.commons.leaderboard
|
|||
|
||||
import android.accounts.Account
|
||||
import android.content.Context
|
||||
import android.os.Looper.getMainLooper
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
|
@ -26,11 +27,14 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.doReturn
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.powermock.reflect.Whitebox
|
||||
import org.robolectric.Robolectric
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.Shadows
|
||||
import org.robolectric.Shadows.shadowOf
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.LooperMode
|
||||
import org.robolectric.shadows.ShadowToast
|
||||
|
|
@ -222,6 +226,7 @@ class LeaderboardFragmentUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testMenuVisibilityOverrideVisibleWithContext() {
|
||||
shadowOf(getMainLooper()).idle()
|
||||
`when`(parentView.context).thenReturn(context)
|
||||
val method: Method = LeaderboardFragment::class.java.getDeclaredMethod(
|
||||
"setMenuVisibility",
|
||||
|
|
@ -229,7 +234,17 @@ class LeaderboardFragmentUnitTests {
|
|||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(fragment, true)
|
||||
Assert.assertEquals(ShadowToast.getTextOfLatestToast().toString(), context.getString(R.string.leaderboard_unavailable_beta))
|
||||
if(isBetaFlavour) {
|
||||
Assert.assertEquals(
|
||||
ShadowToast.getTextOfLatestToast().toString(),
|
||||
context.getString(R.string.leaderboard_unavailable_beta)
|
||||
)
|
||||
} else {
|
||||
Assert.assertNull(
|
||||
ShadowToast.getTextOfLatestToast()
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ import fr.free.nrw.commons.TestAppAdapter
|
|||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.auth.SessionManager
|
||||
import fr.free.nrw.commons.profile.ProfileActivity
|
||||
import fr.free.nrw.commons.utils.ConfigUtils
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
|
@ -372,7 +373,16 @@ class AchievementsFragmentUnitTests {
|
|||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(fragment, true)
|
||||
Assert.assertEquals(ShadowToast.getTextOfLatestToast().toString(), context.getString(R.string.achievements_unavailable_beta))
|
||||
if(ConfigUtils.isBetaFlavour) {
|
||||
Assert.assertEquals(
|
||||
ShadowToast.getTextOfLatestToast().toString(),
|
||||
context.getString(R.string.achievements_unavailable_beta)
|
||||
)
|
||||
} else {
|
||||
Assert.assertNull(
|
||||
ShadowToast.getTextOfLatestToast()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue