mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Convert instrumentation tests to Kotlin (#2689)
* Convert SettingsActivityTest to Kotlin * Convert NavigationBaseActivityTest to Kotlin * Convert UploadTest to Kotlin
This commit is contained in:
parent
0612519e1c
commit
268ba07648
5 changed files with 317 additions and 343 deletions
|
|
@ -0,0 +1,65 @@
|
|||
package fr.free.nrw.commons
|
||||
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.contrib.DrawerActions
|
||||
import androidx.test.espresso.contrib.NavigationViewActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.filters.LargeTest
|
||||
import androidx.test.rule.ActivityTestRule
|
||||
import androidx.test.runner.AndroidJUnit4
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class NavigationBaseActivityTest {
|
||||
@get:Rule
|
||||
var activityRule: ActivityTestRule<*> = ActivityTestRule(AboutActivity::class.java)
|
||||
|
||||
/**
|
||||
* Goes through all the activities in the app and checks we don't crash
|
||||
* NB: This is not realistic if we're not logged in; we can access 'home', 'notifications', 'settings' and 'achievements' which we wouldn't otherwise be able to.
|
||||
*/
|
||||
@Test
|
||||
fun goThroughNavigationBaseActivityActivities() {
|
||||
// Home
|
||||
openNavigationDrawerAndNavigateTo(R.id.action_home)
|
||||
|
||||
// Explore
|
||||
openNavigationDrawerAndNavigateTo(R.id.action_explore)
|
||||
|
||||
// Bookmarks
|
||||
openNavigationDrawerAndNavigateTo(R.id.action_bookmarks)
|
||||
|
||||
// About
|
||||
openNavigationDrawerAndNavigateTo(R.id.action_about)
|
||||
|
||||
// Settings
|
||||
openNavigationDrawerAndNavigateTo(R.id.action_settings)
|
||||
|
||||
// Achievements
|
||||
openNavigationDrawerAndNavigateTo(R.id.action_login)
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks 'Explore' in the navigation drawer twice, then clicks 'home'
|
||||
* Testing to avoid regression of #2200
|
||||
*/
|
||||
@Test
|
||||
fun doubleNavigateToExploreThenReturnHome() {
|
||||
// Explore
|
||||
openNavigationDrawerAndNavigateTo(R.id.action_explore)
|
||||
|
||||
// Explore
|
||||
openNavigationDrawerAndNavigateTo(R.id.action_explore)
|
||||
|
||||
// Home
|
||||
openNavigationDrawerAndNavigateTo(R.id.action_home)
|
||||
}
|
||||
|
||||
private fun openNavigationDrawerAndNavigateTo(menuItemId: Int) {
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
onView(withId(R.id.navigation_view)).perform(NavigationViewActions.navigateTo(menuItemId))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue