[WIP] Adding Espresso test for orientation change (#2814)

* first commit

* initial commit

* added UI test for more activities

* added more tests

* improved code quality

* reverted code
This commit is contained in:
Vanshika Arora 2019-04-02 09:04:05 +05:30 committed by Vivek Maskara
parent dcbf076965
commit 4578600c1e
12 changed files with 129 additions and 6 deletions

View file

@ -1,10 +1,13 @@
package fr.free.nrw.commons
import android.app.Activity
import android.content.pm.ActivityInfo
import androidx.test.espresso.Espresso.closeSoftKeyboard
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.NoMatchingViewException
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.rule.ActivityTestRule
import fr.free.nrw.commons.utils.StringUtils
import timber.log.Timber
@ -57,5 +60,11 @@ class UITestHelper {
throw NotImplementedError("Configure your beta account's password")
} else return password
}
fun <T: Activity> changeOrientation(activityRule: ActivityTestRule<T>){
activityRule.activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
assert(activityRule.activity.requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
activityRule.activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
assert(activityRule.activity.requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
}
}
}