mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Removed butterknife and cleaned up the test (#5446)
This commit is contained in:
parent
87d1255323
commit
56e21ab7c8
2 changed files with 44 additions and 53 deletions
|
|
@ -1,77 +1,60 @@
|
|||
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 androidx.test.core.app.ApplicationProvider
|
||||
import androidx.fragment.app.testing.FragmentScenario
|
||||
import androidx.fragment.app.testing.launchFragmentInContainer
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.profile.ProfileActivity
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.Robolectric
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.Shadows
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.LooperMode
|
||||
import fr.free.nrw.commons.R
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||
@LooperMode(LooperMode.Mode.PAUSED)
|
||||
class MoreBottomSheetLoggedOutFragmentUnitTests {
|
||||
|
||||
private lateinit var fragment: MoreBottomSheetLoggedOutFragment
|
||||
|
||||
private lateinit var context: Context
|
||||
private lateinit var scenario: FragmentScenario<MoreBottomSheetLoggedOutFragment>
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
|
||||
val activity = Robolectric.buildActivity(ProfileActivity::class.java).create().get()
|
||||
fragment = MoreBottomSheetLoggedOutFragment()
|
||||
val fragmentManager: FragmentManager = activity.supportFragmentManager
|
||||
val fragmentTransaction: FragmentTransaction = fragmentManager.beginTransaction()
|
||||
fragmentTransaction.add(fragment, null)
|
||||
fragmentTransaction.commit()
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun checkFragmentNotNull() {
|
||||
Assert.assertNotNull(fragment)
|
||||
scenario = launchFragmentInContainer(
|
||||
initialState = Lifecycle.State.RESUMED,
|
||||
themeResId = R.style.LightAppTheme
|
||||
) {
|
||||
MoreBottomSheetLoggedOutFragment()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnSettingsClicked() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
fragment.onSettingsClicked()
|
||||
scenario.onFragment { it.onSettingsClicked() }
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnAboutClicked() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
fragment.onAboutClicked()
|
||||
scenario.onFragment { it.onAboutClicked() }
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnFeedbackClicked() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
fragment.onFeedbackClicked()
|
||||
scenario.onFragment { it.onFeedbackClicked() }
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnLogoutClicked() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
fragment.onLogoutClicked()
|
||||
scenario.onFragment { it.onLogoutClicked() }
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue