mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 05:43:55 +01:00
* *.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
70 lines
2.5 KiB
Kotlin
70 lines
2.5 KiB
Kotlin
package fr.free.nrw.commons
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import androidx.test.espresso.Espresso
|
|
import androidx.test.espresso.action.ViewActions.click
|
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
|
import androidx.test.espresso.contrib.RecyclerViewActions
|
|
import androidx.test.espresso.matcher.ViewMatchers.isEnabled
|
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
import androidx.test.platform.app.InstrumentationRegistry
|
|
import androidx.test.rule.ActivityTestRule
|
|
import androidx.test.uiautomator.UiDevice
|
|
import com.google.gson.Gson
|
|
import fr.free.nrw.commons.UITestHelper.Companion.childAtPosition
|
|
import fr.free.nrw.commons.kvstore.JsonKvStore
|
|
import fr.free.nrw.commons.settings.SettingsActivity
|
|
import org.hamcrest.CoreMatchers.allOf
|
|
import org.junit.Before
|
|
import org.junit.Rule
|
|
import org.junit.Test
|
|
import org.junit.runner.RunWith
|
|
|
|
@RunWith(AndroidJUnit4::class)
|
|
class SettingsActivityTest {
|
|
private lateinit var defaultKvStore: JsonKvStore
|
|
|
|
@get:Rule
|
|
var activityRule: ActivityTestRule<*> = ActivityTestRule(SettingsActivity::class.java)
|
|
|
|
private val device: UiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
|
|
|
@Before
|
|
fun setup() {
|
|
device.setOrientationNatural()
|
|
device.freezeRotation()
|
|
val context = InstrumentationRegistry.getInstrumentation().targetContext
|
|
val storeName = context.packageName + "_preferences"
|
|
defaultKvStore = JsonKvStore(context, storeName, Gson())
|
|
}
|
|
|
|
@Test
|
|
fun useAuthorNameTogglesOn() {
|
|
// Turn on "Use author name" preference if currently off
|
|
if (!defaultKvStore.getBoolean("useAuthorName", false)) {
|
|
Espresso
|
|
.onView(
|
|
allOf(
|
|
withId(R.id.recycler_view),
|
|
childAtPosition(withId(android.R.id.list_container), 0),
|
|
),
|
|
).perform(
|
|
RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(6, click()),
|
|
)
|
|
}
|
|
// Check authorName preference is enabled
|
|
Espresso
|
|
.onView(
|
|
allOf(
|
|
withId(R.id.recycler_view),
|
|
childAtPosition(withId(android.R.id.list_container), 0),
|
|
),
|
|
).check(matches(isEnabled()))
|
|
}
|
|
|
|
@Test
|
|
fun orientationChange() {
|
|
UITestHelper.changeOrientation(activityRule)
|
|
}
|
|
}
|