Skip to content

Commit

Permalink
Fixes #3435: Added content description for Hints and Solution bulb (#…
Browse files Browse the repository at this point in the history
…3475)

* Added content description for Hints and Solution bulb

* Fixed test cases

Co-authored-by: Rajat Talesra <[email protected]>
  • Loading branch information
rt4914 and Rajat Talesra authored Jul 14, 2021
1 parent 3d055ef commit 984a19c
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class HintsAndSolutionDialogFragmentPresenter @Inject constructor(
this.solutionIndex = solutionIndex
this.isSolutionRevealed = isSolutionRevealed
binding.hintsAndSolutionToolbar.setNavigationIcon(R.drawable.ic_close_white_24dp)
binding.hintsAndSolutionToolbar.setNavigationContentDescription(
R.string.hints_andSolution_close_icon_description
)
binding.hintsAndSolutionToolbar.setNavigationOnClickListener {
(fragment.requireActivity() as? HintsAndSolutionListener)?.dismiss()
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout-land/question_player_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
android:layout_height="6dp"
android:layout_gravity="top|end"
android:layout_margin="8dp"
android:contentDescription="@string/new_hint_available"
android:src="@drawable/ic_dot_yellow_24dp"
android:visibility="@{viewModel.isHintOpenedAndUnRevealed() ? View.VISIBLE : View.GONE}" />

Expand All @@ -155,6 +156,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:contentDescription="@string/show_hints_and_solution"
android:src="@drawable/ic_hint_bulb_white_24dp" />
</FrameLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
android:layout_height="6dp"
android:layout_gravity="top|end"
android:layout_margin="8dp"
android:contentDescription="@string/new_hint_available"
android:src="@drawable/ic_dot_yellow_24dp"
android:visibility="@{viewModel.isHintOpenedAndUnRevealed() ? View.VISIBLE : View.GONE}" />

Expand All @@ -159,6 +160,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:contentDescription="@string/show_hints_and_solution"
android:src="@drawable/ic_hint_bulb_white_24dp" />
</FrameLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
android:layout_height="6dp"
android:layout_gravity="top|end"
android:layout_margin="8dp"
android:contentDescription="@string/new_hint_available"
android:src="@drawable/ic_dot_yellow_24dp"
android:visibility="@{viewModel.isHintOpenedAndUnRevealed() ? View.VISIBLE : View.GONE}" />

Expand All @@ -159,6 +160,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:contentDescription="@string/show_hints_and_solution"
android:src="@drawable/ic_hint_bulb_white_24dp" />
</FrameLayout>

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/question_player_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
android:layout_height="6dp"
android:layout_gravity="top|end"
android:layout_margin="8dp"
android:contentDescription="@string/new_hint_available"
android:src="@drawable/ic_dot_yellow_24dp"
android:visibility="@{viewModel.isHintOpenedAndUnRevealed() ? View.VISIBLE : View.GONE}" />

Expand All @@ -135,6 +136,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:contentDescription="@string/show_hints_and_solution"
android:src="@drawable/ic_hint_bulb_white_24dp" />
</FrameLayout>

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/state_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
android:layout_height="6dp"
android:layout_gravity="top|end"
android:layout_margin="8dp"
android:contentDescription="@string/new_hint_available"
android:src="@drawable/ic_dot_yellow_24dp"
android:visibility="@{viewModel.isHintOpenedAndUnRevealed() ? View.VISIBLE : View.GONE}" />

Expand All @@ -121,6 +122,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:contentDescription="@string/show_hints_and_solution"
android:src="@drawable/ic_hint_bulb_white_24dp" />
</FrameLayout>

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@
<string name="pick_a_different_topic">Pick a \ndifferent topic.</string>
<string name="are_you_interested">Are you interested in:\n%s?</string>
<!-- HintsAndSolutionDialogFragment -->
<string name="new_hint_available">New hint available</string>
<string name="show_hints_and_solution">Show hints and solution</string>
<string name="hints_andSolution_close_icon_description">Navigate up</string>
<string name="hints_toolbar_title">Hints</string>
<string name="reveal_solution">Reveal Solution</string>
<string name="reveal_hint">Reveal Hint</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,77 @@ class StateFragmentTest {
}
}

@Test
fun testStateFragment_forHintsAndSolution_incorrectInputTwice_hintBulbContainerIsVisible() {
launchForExploration(FRACTIONS_EXPLORATION_ID_1).use {
startPlayingExploration()
selectMultipleChoiceOption(
optionPosition = 3,
expectedOptionText = "No, because, in a fraction, the pieces must be the same size."
)
clickContinueNavigationButton()

// Entering incorrect answer twice.
typeFractionText("1/2")
clickSubmitAnswerButton()
scrollToViewType(FRACTION_INPUT_INTERACTION)
typeFractionText("1/2")
clickSubmitAnswerButton()

onView(withId(R.id.hints_and_solution_fragment_container)).check(matches(isDisplayed()))
}
}

@Test
fun testStateFragment_showHintsAndSolutionBulb_dotHasCorrectContentDescription() {
launchForExploration(FRACTIONS_EXPLORATION_ID_1).use {
startPlayingExploration()
selectMultipleChoiceOption(
optionPosition = 3,
expectedOptionText = "No, because, in a fraction, the pieces must be the same size."
)
clickContinueNavigationButton()

// Entering incorrect answer twice.
typeFractionText("1/2")
clickSubmitAnswerButton()
scrollToViewType(FRACTION_INPUT_INTERACTION)
typeFractionText("1/2")
clickSubmitAnswerButton()

onView(withId(R.id.dot_hint)).check(
matches(
withContentDescription(R.string.new_hint_available)
)
)
}
}

@Test
fun testStateFragment_showHintsAndSolutionBulb_bulbHasCorrectContentDescription() {
launchForExploration(FRACTIONS_EXPLORATION_ID_1).use {
startPlayingExploration()
selectMultipleChoiceOption(
optionPosition = 3,
expectedOptionText = "No, because, in a fraction, the pieces must be the same size."
)
clickContinueNavigationButton()

// Entering incorrect answer twice.
typeFractionText("1/2")
clickSubmitAnswerButton()
scrollToViewType(FRACTION_INPUT_INTERACTION)
typeFractionText("1/2")
clickSubmitAnswerButton()

onView(withId(R.id.hint_bulb)).check(
matches(
withContentDescription(R.string.show_hints_and_solution)
)
)
}
}

@Test
fun testStateFragment_forMisconception_showsLinkTextForConceptCard() {
launchForExploration(FRACTIONS_EXPLORATION_ID_1).use {
Expand Down

0 comments on commit 984a19c

Please sign in to comment.