mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Issue-5662-kotlinstyle (#5833)
* *.kt: bulk correction of formatting using ktlint --format * *.kt: replace wildcard imports and second stage auto format ktlint --format * QuizQuestionTest.kt: modified property names to camel case to meet ktlint standard * LevelControllerTest.kt: modified property names to camel case to meet ktlint standard * QuizActivityUnitTest.kt: modified property names to camel case to meet ktlint standard * MediaDetailFragmentUnitTests.kt: modified property names to camel case to meet ktlint standard * UploadWorker.kt: modified property names to camel case to meet ktlint standard * UploadClient.kt: modified property names to camel case to meet ktlint standard * BasePagingPresenter.kt: modified property names to camel case to meet ktlint standard * DescriptionEditActivity.kt: modified property names to camel case to meet ktlint standard * OnSwipeTouchListener.kt: modified property names to camel case to meet ktlint standard * MediaDetailFragmentUnitTests.kt: corrected excessive line length to meet ktlint standard * DepictedItem.kt: corrected property name format and catch format to for ktlint standard * UploadCategoryAdapter.kt: corrected class definition format to meet ktlint standard * CustomSelectorActivity.kt: reformatted function names to first letter lowercase to meet ktlint standard * MediaDetailFragmentUnitTests.kt: fix string literal indentation to meet ktlint standard * NotForUploadDao.kt: file renamed to match class name, new file NotForUploadStatusDao.kt * UploadedDao.kt: file renamed to match class name, new file UploadedStatusDao.kt * Urls.kt: fixed excessive line length for ktLint standard * Snak_partial.kt & Statement_partial.kt: refactored to remove underscores in class names to meet ktLint standard * *.kt: fixed consecutive KDOC error for ktLint * PageableBaseDataSourceTest.kt & UploadPresenterTest.kt: fixed excessive line lengths to meet ktLint standard * CheckboxTriStatesTest.kt: renamed file to match class name to meet ktLint standard * .kt: resolved backing-property-naming error in ktLint, made matching properties public, matched names and refactored * TestConnectionFactory.kt: fixed property naming to adhere to ktLint standard
This commit is contained in:
parent
950539c55c
commit
2d82a430c4
405 changed files with 11032 additions and 9137 deletions
|
|
@ -10,17 +10,20 @@ import androidx.test.espresso.action.ViewActions
|
|||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.rule.ActivityTestRule
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import org.hamcrest.*
|
||||
import org.hamcrest.BaseMatcher
|
||||
import org.hamcrest.Description
|
||||
import org.hamcrest.Matcher
|
||||
import org.hamcrest.Matchers
|
||||
import org.hamcrest.TypeSafeMatcher
|
||||
import timber.log.Timber
|
||||
|
||||
|
||||
class UITestHelper {
|
||||
companion object {
|
||||
fun skipWelcome() {
|
||||
try {
|
||||
onView(ViewMatchers.withId(R.id.button_ok))
|
||||
.perform(ViewActions.click())
|
||||
//Skip tutorial
|
||||
// Skip tutorial
|
||||
onView(ViewMatchers.withId(R.id.finishTutorialButton))
|
||||
.perform(ViewActions.click())
|
||||
} catch (ignored: NoMatchingViewException) {
|
||||
|
|
@ -29,27 +32,31 @@ class UITestHelper {
|
|||
|
||||
fun skipLogin() {
|
||||
try {
|
||||
//Skip Login
|
||||
val htmlTextView = onView(
|
||||
Matchers.allOf(
|
||||
ViewMatchers.withId(R.id.skip_login), ViewMatchers.withText("Skip"),
|
||||
ViewMatchers.isDisplayed()
|
||||
// Skip Login
|
||||
val htmlTextView =
|
||||
onView(
|
||||
Matchers.allOf(
|
||||
ViewMatchers.withId(R.id.skip_login),
|
||||
ViewMatchers.withText("Skip"),
|
||||
ViewMatchers.isDisplayed(),
|
||||
),
|
||||
)
|
||||
)
|
||||
htmlTextView.perform(ViewActions.click())
|
||||
|
||||
val appCompatButton = onView(
|
||||
Matchers.allOf(
|
||||
ViewMatchers.withId(android.R.id.button1), ViewMatchers.withText("Yes"),
|
||||
childAtPosition(
|
||||
val appCompatButton =
|
||||
onView(
|
||||
Matchers.allOf(
|
||||
ViewMatchers.withId(android.R.id.button1),
|
||||
ViewMatchers.withText("Yes"),
|
||||
childAtPosition(
|
||||
ViewMatchers.withId(R.id.buttonPanel),
|
||||
0
|
||||
childAtPosition(
|
||||
ViewMatchers.withId(R.id.buttonPanel),
|
||||
0,
|
||||
),
|
||||
3,
|
||||
),
|
||||
3
|
||||
)
|
||||
),
|
||||
)
|
||||
)
|
||||
appCompatButton.perform(ViewActions.scrollTo(), ViewActions.click())
|
||||
} catch (ignored: NoMatchingViewException) {
|
||||
}
|
||||
|
|
@ -57,18 +64,18 @@ class UITestHelper {
|
|||
|
||||
fun loginUser() {
|
||||
try {
|
||||
//Perform Login
|
||||
// Perform Login
|
||||
sleep(3000)
|
||||
onView(ViewMatchers.withId(R.id.login_username))
|
||||
.perform(
|
||||
ViewActions.replaceText(getTestUsername()),
|
||||
ViewActions.closeSoftKeyboard()
|
||||
ViewActions.closeSoftKeyboard(),
|
||||
)
|
||||
sleep(2000)
|
||||
onView(ViewMatchers.withId(R.id.login_password))
|
||||
.perform(
|
||||
ViewActions.replaceText(getTestUserPassword()),
|
||||
ViewActions.closeSoftKeyboard()
|
||||
ViewActions.closeSoftKeyboard(),
|
||||
)
|
||||
sleep(2000)
|
||||
onView(ViewMatchers.withId(R.id.login_button))
|
||||
|
|
@ -76,7 +83,6 @@ class UITestHelper {
|
|||
sleep(10000)
|
||||
} catch (ignored: NoMatchingViewException) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun logoutUser() {
|
||||
|
|
@ -87,36 +93,38 @@ class UITestHelper {
|
|||
childAtPosition(
|
||||
childAtPosition(
|
||||
ViewMatchers.withId(R.id.fragment_main_nav_tab_layout),
|
||||
0
|
||||
0,
|
||||
),
|
||||
4
|
||||
4,
|
||||
),
|
||||
ViewMatchers.isDisplayed()
|
||||
)
|
||||
ViewMatchers.isDisplayed(),
|
||||
),
|
||||
).perform(ViewActions.click())
|
||||
onView(
|
||||
Matchers.allOf(
|
||||
ViewMatchers.withId(R.id.more_logout), ViewMatchers.withText("Logout"),
|
||||
ViewMatchers.withId(R.id.more_logout),
|
||||
ViewMatchers.withText("Logout"),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
ViewMatchers.withId(R.id.scroll_view_more_bottom_sheet),
|
||||
0
|
||||
0,
|
||||
),
|
||||
6
|
||||
)
|
||||
)
|
||||
6,
|
||||
),
|
||||
),
|
||||
).perform(ViewActions.scrollTo(), ViewActions.click())
|
||||
onView(
|
||||
Matchers.allOf(
|
||||
ViewMatchers.withId(android.R.id.button1), ViewMatchers.withText("Yes"),
|
||||
ViewMatchers.withId(android.R.id.button1),
|
||||
ViewMatchers.withText("Yes"),
|
||||
childAtPosition(
|
||||
childAtPosition(
|
||||
ViewMatchers.withId(R.id.buttonPanel),
|
||||
0
|
||||
0,
|
||||
),
|
||||
3
|
||||
)
|
||||
)
|
||||
3,
|
||||
),
|
||||
),
|
||||
).perform(ViewActions.scrollTo(), ViewActions.click())
|
||||
sleep(5000)
|
||||
} catch (ignored: NoMatchingViewException) {
|
||||
|
|
@ -124,9 +132,9 @@ class UITestHelper {
|
|||
}
|
||||
|
||||
fun childAtPosition(
|
||||
parentMatcher: Matcher<View>, position: Int
|
||||
parentMatcher: Matcher<View>,
|
||||
position: Int,
|
||||
): Matcher<View> {
|
||||
|
||||
return object : TypeSafeMatcher<View>() {
|
||||
override fun describeTo(description: Description) {
|
||||
description.appendText("Child at position $position in parent ")
|
||||
|
|
@ -135,8 +143,9 @@ class UITestHelper {
|
|||
|
||||
public override fun matchesSafely(view: View): Boolean {
|
||||
val parent = view.parent
|
||||
return parent is ViewGroup && parentMatcher.matches(parent)
|
||||
&& view == parent.getChildAt(position)
|
||||
return parent is ViewGroup &&
|
||||
parentMatcher.matches(parent) &&
|
||||
view == parent.getChildAt(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -154,14 +163,18 @@ class UITestHelper {
|
|||
val username = BuildConfig.TEST_USERNAME
|
||||
if (StringUtils.isEmpty(username) || username == "null") {
|
||||
throw NotImplementedError("Configure your beta account's username")
|
||||
} else return username
|
||||
} else {
|
||||
return username
|
||||
}
|
||||
}
|
||||
|
||||
private fun getTestUserPassword(): String {
|
||||
val password = BuildConfig.TEST_PASSWORD
|
||||
if (StringUtils.isEmpty(password) || password == "null") {
|
||||
throw NotImplementedError("Configure your beta account's password")
|
||||
} else return password
|
||||
} else {
|
||||
return password
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Activity> changeOrientation(activityRule: ActivityTestRule<T>) {
|
||||
|
|
@ -174,6 +187,7 @@ class UITestHelper {
|
|||
fun <T> first(matcher: Matcher<T>): Matcher<T>? {
|
||||
return object : BaseMatcher<T>() {
|
||||
var isFirst = true
|
||||
|
||||
override fun matches(item: Any): Boolean {
|
||||
if (isFirst && matcher.matches(item)) {
|
||||
isFirst = false
|
||||
|
|
@ -188,4 +202,4 @@ class UITestHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue