mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
* Fix AboutActivity Instrumentation Tests * Fix WelcomeActivity Instrumentation Tests * Fix SearchActivity Instrumentation Tests * Fix SignupTest Instrumentation Tests * Fix LoginActivityTest Instrumentation Tests * Fix SettingsActivity Instrumentation Tests * Fix LoginActivity Instrumentation Tests * Update loginUser * Add logoutUser * Fix logoutUser * Update github action to use env variables * Fix github action to use env variables * Fix github action * Fix github action * Fix github action * Fix github action * Fix github action * Fix github action * Fix github action * Fix github action * Fix github action * Fix github action * Fix github action * Remove scroll * Add wait time * Fix keyboard issue * Disable animation * Enable animation * Enable animation * Disable animation * Fix compile error * Remove AVD Cache * Set timezone and dns * Add AVD cache * Add API level * Update API level to 24 * Add sleep timer * Add scroll * Remove logout * Ignore some tests * update logout * update logout * Fix scroll layout problem * Fix scroll layout problem * Ignore orientation test * Update tests * Update tests * Update API level to 29 * Change device and API level to 27 * Use AndroidJUnit4 * Change API to 28 * Try with macos * Use nested scrollview * Update Profile Activity Test * Update Profile Activity Test * Turn off rotation * Change device * Remove failing test * Change API to 24 * Add rotation lock for failing test * Change API to 24 * Add sleep * Remove text * Remove child * Force rotation on back press * Force open more sheet * Change device to pixel 5 * Change device to 13.5inch * Update tests * Ignore failing test * Use linux * Update tests * Use repo secrets instead * Add mainactivity tests * Remove content description * Different workflows for PR and branch, PR workflow will need maintainer approval to prevent secrets getting leaked * Run instrumentation tests only for push and not for PRs * Fix FileNotFound Exception * Update MainActivity and Profile tests * Fix coverage path issue * Add wait time for map to load * Open contribution * Update settings tests * Update main activity tests * Fix failing test * Fix failing test * Increase login time * Separate settings test * Update review tests * Ignore uploadCancelledAfterLocationPickedTest * Update MainActivity Tests * Update UploadCancelledTest * Update UploadCancelledTest * Update device * Fix Init release error * Fix failing test * Fix failing test * Try with long click * Update UploadCancelledTest.kt * Fix Leaderboard Test * Update testContributions * Set GPS coordinates * Add zoomControllers to excludes * Add ExploreActivityTest * Remove failing condition * Merge tests * Remove failing test * Remove failing test * Fix failing test * Fix failing test * Update AboutActivityTest.kt * Update jacoco.gradle
133 lines
No EOL
4.1 KiB
Kotlin
133 lines
No EOL
4.1 KiB
Kotlin
package fr.free.nrw.commons
|
|
|
|
import androidx.test.espresso.Espresso.onView
|
|
import androidx.test.espresso.action.ViewActions
|
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
|
import androidx.test.espresso.matcher.ViewMatchers
|
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
import androidx.test.filters.LargeTest
|
|
import androidx.test.platform.app.InstrumentationRegistry
|
|
import androidx.test.rule.ActivityTestRule
|
|
import androidx.test.uiautomator.UiDevice
|
|
import androidx.viewpager.widget.ViewPager
|
|
import fr.free.nrw.commons.utils.ConfigUtils
|
|
import org.hamcrest.core.IsNot.not
|
|
import org.junit.Before
|
|
import org.junit.Rule
|
|
import org.junit.Test
|
|
import org.junit.runner.RunWith
|
|
|
|
@LargeTest
|
|
@RunWith(AndroidJUnit4::class)
|
|
class WelcomeActivityTest {
|
|
|
|
@get:Rule
|
|
var activityRule: ActivityTestRule<*> = ActivityTestRule(WelcomeActivity::class.java)
|
|
|
|
private val device: UiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
|
|
|
@Before
|
|
fun setup() {
|
|
device.setOrientationNatural()
|
|
device.freezeRotation()
|
|
}
|
|
|
|
@Test
|
|
fun ifBetaShowsSkipButton() {
|
|
if (ConfigUtils.isBetaFlavour) {
|
|
onView(withId(R.id.button_ok))
|
|
.perform(ViewActions.click())
|
|
onView(withId(R.id.finishTutorialButton))
|
|
.check(matches(isDisplayed()))
|
|
}
|
|
}
|
|
|
|
@Test
|
|
fun ifProdHidesSkipButton() {
|
|
if (!ConfigUtils.isBetaFlavour) {
|
|
onView(withId(R.id.button_ok))
|
|
.perform(ViewActions.click())
|
|
onView(withId(R.id.finishTutorialButton))
|
|
.check(matches(not(isDisplayed())))
|
|
}
|
|
}
|
|
|
|
@Test
|
|
fun testBetaSkipButton() {
|
|
if (ConfigUtils.isBetaFlavour) {
|
|
onView(withId(R.id.button_ok))
|
|
.perform(ViewActions.click())
|
|
onView(withId(R.id.finishTutorialButton))
|
|
.perform(ViewActions.click())
|
|
assert(activityRule.activity.isDestroyed)
|
|
}
|
|
}
|
|
|
|
@Test
|
|
fun testSwipingOnce() {
|
|
onView(withId(R.id.button_ok))
|
|
.perform(ViewActions.click())
|
|
onView(withId(R.id.welcomePager))
|
|
.perform(ViewActions.swipeLeft())
|
|
assert(true)
|
|
onView(withId(R.id.welcomePager))
|
|
.perform(ViewActions.swipeRight())
|
|
assert(true)
|
|
}
|
|
|
|
@Test
|
|
fun testSwipingWholeTutorial() {
|
|
onView(withId(R.id.button_ok))
|
|
.perform(ViewActions.click())
|
|
onView(withId(R.id.welcomePager))
|
|
.perform(ViewActions.swipeLeft())
|
|
.perform(ViewActions.swipeLeft())
|
|
.perform(ViewActions.swipeLeft())
|
|
.perform(ViewActions.swipeLeft())
|
|
assert(true)
|
|
onView(withId(R.id.welcomePager))
|
|
.perform(ViewActions.swipeRight())
|
|
.perform(ViewActions.swipeRight())
|
|
.perform(ViewActions.swipeRight())
|
|
.perform(ViewActions.swipeRight())
|
|
assert(true)
|
|
}
|
|
|
|
@Test
|
|
fun swipeBeyondBounds() {
|
|
val viewPager = activityRule.activity.findViewById<ViewPager>(R.id.welcomePager)
|
|
|
|
viewPager.adapter?.let {
|
|
if (viewPager.currentItem == 3) {
|
|
onView(withId(R.id.welcomePager))
|
|
.perform(ViewActions.swipeLeft())
|
|
assert(true)
|
|
onView(withId(R.id.welcomePager))
|
|
.perform(ViewActions.swipeRight())
|
|
assert(false)
|
|
}
|
|
}
|
|
}
|
|
|
|
@Test
|
|
fun swipeTillLastAndFinish() {
|
|
val viewPager = activityRule.activity.findViewById<ViewPager>(R.id.welcomePager)
|
|
|
|
viewPager.adapter?.let {
|
|
if (viewPager.currentItem == 3) {
|
|
onView(withId(R.id.button_ok))
|
|
.perform(ViewActions.click())
|
|
onView(withId(R.id.finishTutorialButton))
|
|
.perform(ViewActions.click())
|
|
assert(activityRule.activity.isDestroyed)
|
|
}
|
|
}
|
|
}
|
|
|
|
@Test
|
|
fun orientationChange() {
|
|
UITestHelper.changeOrientation(activityRule)
|
|
}
|
|
} |