mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
* refactor: replace unused exception variable with underscore * refactor: code style fix * fix: remove unnecessary latLng variable and return null directly * fix: use explicit true/false instead of isFABsExpanded * refactor: simplify marker update logic by reducing redundant conditions * refactor: use data object instead of object * fix: check placeBindings for null instead of checking each destructured value * fix: check placeBindings for null instead of checking each destructured value * docs: fix KDoc for contentUri property by removing incorrect @param tag * docs: correct @see link in KDoc for showBadgesWithCount * docs: fix KDoc tag from @property to @param for context in BottomSheetAdapter * docs: comment out KDoc for disabled method to avoid unresolved @param warning * docs: fix KDoc for onLongPress by removing invalid @param imageUri * docs: clean up invalid KDoc tags on property and add docs to isEmpty * docs: remove invalid @param originalImageCoordinates from findOtherImages KDoc * docs: fix incorrect @param tag in checkDuplicateImage KDoc * docs: fix incorrect @param in onLongPress KDoc * docs: fix invalid @param and @return tags on author property * docs: fix incorrect @param in provideWikidataMediaInterface KDoc * docs: fix incorrect @param name in getWikiText KDoc * docs: escape wikilinks with [[ ]] to avoid KDoc resolution warnings * docs: fix KDoc by adding missing param descriptions to startActivityWithFlags * docs: fix KDoc by replacing @param with @property for contentUri * docs: fix malformed KDoc in startYourself, remove invalid @param line * docs: remove invalid @param tag in createDialogsAndHandleLocationPermissions * docs: remove invalid @param tags to @property * @docs: remove invalid @property tags * docs: clean up KDoc by removing invalid @param and @return tags * docs: fix incorrect @param name in removeBlocklisted KDoc * docs: fix incorrect @param name in checkDuplicateImage KDoc * docs: fix incorrect @param tag --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
203 lines
6.3 KiB
Kotlin
203 lines
6.3 KiB
Kotlin
package fr.free.nrw.commons
|
|
|
|
import android.app.Activity
|
|
import android.app.Instrumentation
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import androidx.test.espresso.Espresso.onView
|
|
import androidx.test.espresso.action.ViewActions.click
|
|
import androidx.test.espresso.action.ViewActions.closeSoftKeyboard
|
|
import androidx.test.espresso.action.ViewActions.replaceText
|
|
import androidx.test.espresso.action.ViewActions.scrollTo
|
|
import androidx.test.espresso.contrib.RecyclerViewActions
|
|
import androidx.test.espresso.intent.Intents
|
|
import androidx.test.espresso.intent.matcher.IntentMatchers
|
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
|
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.rule.GrantPermissionRule
|
|
import androidx.test.uiautomator.UiDevice
|
|
import fr.free.nrw.commons.locationpicker.LocationPickerActivity
|
|
import fr.free.nrw.commons.UITestHelper.Companion.childAtPosition
|
|
import fr.free.nrw.commons.auth.LoginActivity
|
|
import org.hamcrest.CoreMatchers
|
|
import org.hamcrest.Matchers.allOf
|
|
import org.junit.After
|
|
import org.junit.Before
|
|
import org.junit.Rule
|
|
import org.junit.Test
|
|
import org.junit.runner.RunWith
|
|
|
|
@RunWith(AndroidJUnit4::class)
|
|
class UploadCancelledTest {
|
|
@Rule
|
|
@JvmField
|
|
var mActivityTestRule = ActivityTestRule(LoginActivity::class.java)
|
|
|
|
@Rule
|
|
@JvmField
|
|
var mGrantPermissionRule: GrantPermissionRule =
|
|
GrantPermissionRule.grant(
|
|
"android.permission.WRITE_EXTERNAL_STORAGE",
|
|
)
|
|
|
|
private val device: UiDevice =
|
|
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
|
|
|
@Before
|
|
fun setup() {
|
|
try {
|
|
Intents.init()
|
|
} catch (_: IllegalStateException) {
|
|
}
|
|
device.unfreezeRotation()
|
|
device.setOrientationNatural()
|
|
device.freezeRotation()
|
|
UITestHelper.loginUser()
|
|
UITestHelper.skipWelcome()
|
|
Intents
|
|
.intending(CoreMatchers.not(IntentMatchers.isInternal()))
|
|
.respondWith(Instrumentation.ActivityResult(Activity.RESULT_OK, null))
|
|
}
|
|
|
|
@After
|
|
fun teardown() {
|
|
try {
|
|
Intents.release()
|
|
} catch (_: IllegalStateException) {
|
|
}
|
|
}
|
|
|
|
@Test
|
|
fun uploadCancelledAfterLocationPickedTest() {
|
|
val bottomNavigationItemView =
|
|
onView(
|
|
allOf(
|
|
childAtPosition(
|
|
childAtPosition(
|
|
withId(R.id.fragment_main_nav_tab_layout),
|
|
0,
|
|
),
|
|
1,
|
|
),
|
|
isDisplayed(),
|
|
),
|
|
)
|
|
bottomNavigationItemView.perform(click())
|
|
|
|
UITestHelper.sleep(12000)
|
|
|
|
val actionMenuItemView =
|
|
onView(
|
|
allOf(
|
|
withId(R.id.list_sheet),
|
|
childAtPosition(
|
|
childAtPosition(
|
|
withId(R.id.toolbar),
|
|
1,
|
|
),
|
|
0,
|
|
),
|
|
isDisplayed(),
|
|
),
|
|
)
|
|
actionMenuItemView.perform(click())
|
|
|
|
val recyclerView =
|
|
onView(
|
|
allOf(
|
|
withId(R.id.rv_nearby_list),
|
|
),
|
|
)
|
|
recyclerView.perform(
|
|
RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(
|
|
0,
|
|
click(),
|
|
),
|
|
)
|
|
|
|
val linearLayout3 =
|
|
onView(
|
|
allOf(
|
|
withId(R.id.cameraButton),
|
|
childAtPosition(
|
|
allOf(
|
|
withId(R.id.nearby_button_layout),
|
|
),
|
|
0,
|
|
),
|
|
isDisplayed(),
|
|
),
|
|
)
|
|
linearLayout3.perform(click())
|
|
|
|
val pasteSensitiveTextInputEditText =
|
|
onView(
|
|
allOf(
|
|
withId(R.id.caption_item_edit_text),
|
|
childAtPosition(
|
|
childAtPosition(
|
|
withId(R.id.caption_item_edit_text_input_layout),
|
|
0,
|
|
),
|
|
0,
|
|
),
|
|
isDisplayed(),
|
|
),
|
|
)
|
|
pasteSensitiveTextInputEditText.perform(replaceText("test"), closeSoftKeyboard())
|
|
|
|
val pasteSensitiveTextInputEditText2 =
|
|
onView(
|
|
allOf(
|
|
withId(R.id.description_item_edit_text),
|
|
childAtPosition(
|
|
childAtPosition(
|
|
withId(R.id.description_item_edit_text_input_layout),
|
|
0,
|
|
),
|
|
0,
|
|
),
|
|
isDisplayed(),
|
|
),
|
|
)
|
|
pasteSensitiveTextInputEditText2.perform(replaceText("test"), closeSoftKeyboard())
|
|
|
|
val appCompatButton2 =
|
|
onView(
|
|
allOf(
|
|
withId(R.id.btn_next),
|
|
childAtPosition(
|
|
childAtPosition(
|
|
withId(R.id.ll_container_media_detail),
|
|
2,
|
|
),
|
|
1,
|
|
),
|
|
isDisplayed(),
|
|
),
|
|
)
|
|
appCompatButton2.perform(click())
|
|
|
|
val appCompatButton3 =
|
|
onView(
|
|
allOf(
|
|
withId(android.R.id.button1),
|
|
),
|
|
)
|
|
appCompatButton3.perform(scrollTo(), click())
|
|
|
|
Intents.intended(IntentMatchers.hasComponent(LocationPickerActivity::class.java.name))
|
|
|
|
val floatingActionButton3 =
|
|
onView(
|
|
allOf(
|
|
withId(R.id.location_chosen_button),
|
|
isDisplayed(),
|
|
),
|
|
)
|
|
UITestHelper.sleep(2000)
|
|
floatingActionButton3.perform(click())
|
|
}
|
|
}
|