Skip to content

Commit

Permalink
Fix oppia#3904: [A11Y] Optimised Add Profile Flow (oppia#3929)
Browse files Browse the repository at this point in the history
* Optimised Add Profile Flow

* Fixed test case
  • Loading branch information
rt4914 committed Oct 22, 2021
1 parent a0769cc commit b0c98e7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import android.graphics.PorterDuff
import android.graphics.drawable.Drawable
import android.net.Uri
import android.provider.MediaStore
import android.view.KeyEvent
import android.view.View
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.ImageView
import androidx.appcompat.app.AlertDialog
Expand Down Expand Up @@ -164,15 +162,6 @@ class AddProfileActivityPresenter @Inject constructor(
}
}

binding.addProfileActivityConfirmPinEditText.setOnEditorActionListener { _, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_DONE ||
(event != null && (event.keyCode == KeyEvent.KEYCODE_ENTER))
) {
binding.addProfileActivityCreateButton.callOnClick()
}
false
}

if (profileViewModel.showInfoAlertPopup.get()!!) {
showInfoDialog()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.test.core.app.ApplicationProvider
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.pressImeActionButton
import androidx.test.espresso.action.ViewActions.scrollTo
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.intent.Intents
Expand Down Expand Up @@ -992,6 +993,42 @@ class AddProfileActivityTest {
}
}

@Test
fun testAddProfileActivity_inputCorrectPinAndConfirmPin_actionDone_buttonIsVisible() {
launch(AddProfileActivity::class.java).use {
onView(
allOf(
withId(R.id.add_profile_activity_user_name_edit_text),
isDescendantOfA(withId(R.id.add_profile_activity_user_name))
)
).perform(scrollTo()).perform(
editTextInputAction.appendText("test"), closeSoftKeyboard()
)
onView(withId(R.id.add_profile_activity_pin_check_box)).perform(scrollTo())
onView(withId(R.id.add_profile_activity_pin_check_box)).perform(click())
onView(
allOf(
withId(R.id.add_profile_activity_pin_edit_text),
isDescendantOfA(withId(R.id.add_profile_activity_pin))
)
).perform(scrollTo()).perform(
editTextInputAction.appendText("123"),
closeSoftKeyboard()
)
onView(
allOf(
withId(R.id.add_profile_activity_confirm_pin_edit_text),
isDescendantOfA(withId(R.id.add_profile_activity_confirm_pin))
)
).perform(scrollTo()).perform(
editTextInputAction.appendText("123"),
pressImeActionButton()
)
onView(withId(R.id.add_profile_activity_create_button)).perform(scrollTo())
onView(withId(R.id.add_profile_activity_create_button)).check(matches(isDisplayed()))
}
}

@Test
fun testAddProfileActivity_inputPin_checkAllowDownloadIsDisabled() {
launch(AddProfileActivity::class.java).use {
Expand Down

0 comments on commit b0c98e7

Please sign in to comment.