Skip to content

Commit

Permalink
Fixes part of oppia#3251: Added hint to numeric input (oppia#3253)
Browse files Browse the repository at this point in the history
* Added hint to numeric input

* Removed content description

* Added test

Co-authored-by: Rajat Talesra <[email protected]>
  • Loading branch information
rt4914 and Rajat Talesra committed Jun 22, 2021
1 parent 17c6a50 commit 6a7e596
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/src/main/res/layout/numeric_input_interaction_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<org.oppia.android.app.customview.interaction.NumericInputInteractionView
android:id="@+id/numeric_input_interaction_view"
style="@style/InputInteractionEditText"
android:contentDescription="@string/numeric_input_content_description"
android:digits="0123456789.-"
android:hint="@string/numeric_input_hint"
android:inputType="numberDecimal"
android:text="@={viewModel.answerText}"
app:textChangedListener="@{viewModel.answerTextWatcher}" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<string name="text_input_default_content_description">Enter text.</string>
<string name="fractions_default_hint_text">Enter a fraction in the form x/x, or a mixed number in the form x x/x.</string>
<string name="fractions_default_hint_text_no_integer">Enter a fraction in the form x/x.</string>
<string name="numeric_input_content_description">Enter a number.</string>
<string name="numeric_input_hint">Enter a number.</string>
<string name="number_with_units_input_hint_text">Write numbers with units here.</string>
<string name="enable_audio_playback_content_description">Enable audio voiceover for this lesson.</string>
<string name="recently_played_stories">Recently-Played Stories</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isEnabled
import androidx.test.espresso.matcher.ViewMatchers.isFocusable
import androidx.test.espresso.matcher.ViewMatchers.isRoot
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withHint
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.espresso.util.HumanReadables
Expand Down Expand Up @@ -1244,6 +1245,23 @@ class StateFragmentTest {
}
}

@Test
fun testStateFragment_interactions_numericInputInteraction_hasCorrectHint() {
launchForExploration(TEST_EXPLORATION_ID_2).use {
startPlayingExploration()
playThroughPrototypeState1()
playThroughPrototypeState2()
playThroughPrototypeState3()
playThroughPrototypeState4()
// Multi-selection item selection.
playThroughPrototypeState5()

// Verify that the user is now on the sixth state.
verifyViewTypeIsPresent(NUMERIC_INPUT_INTERACTION)
verifyHint(context.resources.getString(R.string.numeric_input_hint))
}
}

@Test
fun testStateFragment_interactions_ratioInputInteraction_canSuccessfullySubmitAnswer() {
launchForExploration(TEST_EXPLORATION_ID_2).use {
Expand Down Expand Up @@ -1697,6 +1715,17 @@ class StateFragmentTest {
).check(matches(withText(containsString(expectedHtml))))
}

private fun verifyHint(hint: String) {
scrollToViewType(NUMERIC_INPUT_INTERACTION)
onView(
atPositionOnView(
recyclerViewId = R.id.state_recycler_view,
position = 1,
targetViewId = R.id.numeric_input_interaction_view
)
).check(matches(withHint(containsString(hint))))
}

private fun verifyViewTypeIsPresent(viewType: StateItemViewModel.ViewType) {
// Attempting to scroll to the specified view type is sufficient to verify that it's present.
scrollToViewType(viewType)
Expand Down

0 comments on commit 6a7e596

Please sign in to comment.