From a261b90910a07e2b24ef00d34af2b7c24237ab89 Mon Sep 17 00:00:00 2001 From: Jonathan Alvares Date: Thu, 25 Mar 2021 15:17:03 +0530 Subject: [PATCH] Added accessibilty label to the RevisionCardActivity --- app/src/main/AndroidManifest.xml | 3 +- app/src/main/res/values/strings.xml | 1 + .../revisioncard/RevisionCardActivityTest.kt | 58 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a2aef32494b..a611db47c51 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -157,7 +157,8 @@ android:theme="@style/OppiaThemeWithoutActionBar" /> + android:theme="@style/OppiaThemeWithoutActionBar" + android:label="@string/revision_card_activity_title" /> Coming Soon Recommended Stories Stories For You + Skill page diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt new file mode 100644 index 00000000000..c0249eea13f --- /dev/null +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt @@ -0,0 +1,58 @@ +package org.oppia.android.app.topic.revisioncard + +import android.content.Context +import android.content.Intent +import androidx.test.core.app.ApplicationProvider +import androidx.test.rule.ActivityTestRule +import com.google.common.truth.Truth.assertThat +import org.junit.Rule +import org.junit.Test +import org.oppia.android.R +import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 +import javax.inject.Inject + +class RevisionCardActivityTest { + + @Inject + lateinit var context: Context + + private val internalProfileId = 0 + + private val subTopicId = 0 + + private fun createRevisionCardActivityIntent( + internalProfileId: Int, + topicId: String, + subTopicId: Int + ): Intent { + return RevisionCardActivity.createRevisionCardActivityIntent( + ApplicationProvider.getApplicationContext(), + internalProfileId, + topicId, + subTopicId + ) + } + + @get:Rule + val activityTestRule: ActivityTestRule = ActivityTestRule( + RevisionCardActivity::class.java, + /* initialTouchMode= */ true, + /* launchActivity= */ false + ) + + @Test + fun testRevisionCardActivity_hasCorrectLabel() { + activityTestRule.launchActivity( + createRevisionCardActivityIntent( + internalProfileId = internalProfileId, + topicId = TEST_TOPIC_ID_0, + subTopicId = subTopicId + ) + ) + val title = activityTestRule.activity.title + + // Verify that the activity label is correct as a proxy to verify TalkBack will announce the + // correct string when it's read out. + assertThat(title).isEqualTo(context.getString(R.string.revision_card_activity_title)) + } +}