Skip to content

Commit

Permalink
Fix #2810: Added label for CompletedStoryListActivity (#2949)
Browse files Browse the repository at this point in the history
* Added label to CompletedStoryListActivityTest for Talkback

* Applied suggested changes

* Applied suggested change
  • Loading branch information
ChiragKalra authored Mar 23, 2021
1 parent 0beabc7 commit fe5bc07
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.completedstorylist.CompletedStoryListActivity"
android:label="@string/completed_story_list_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.help.faq.FAQListActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:minHeight="?attr/actionBarSize"
app:navigationContentDescription="@string/navigate_up"
app:navigationIcon="?attr/homeAsUpIndicator"
app:title="@string/stories_completed"
app:title="@string/completed_story_list_activity_title"
app:titleTextAppearance="@style/ToolbarTextAppearance"
app:titleTextColor="@color/white" />
</com.google.android.material.appbar.AppBarLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:minHeight="?attr/actionBarSize"
app:navigationContentDescription="@string/navigate_up"
app:navigationIcon="?attr/homeAsUpIndicator"
app:title="@string/stories_completed"
app:title="@string/completed_story_list_activity_title"
app:titleTextAppearance="@style/ToolbarTextAppearance"
app:titleTextColor="@color/white" />
</com.google.android.material.appbar.AppBarLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
app:titleTextAppearance="@style/ToolbarTextAppearance"
app:navigationContentDescription="@string/navigate_up"
app:navigationIcon="?attr/homeAsUpIndicator"
app:title="@string/stories_completed"
app:title="@string/completed_story_list_activity_title"
app:titleTextColor="@color/white" />
</com.google.android.material.appbar.AppBarLayout>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/completed_story_list_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:minHeight="?attr/actionBarSize"
app:navigationContentDescription="@string/navigate_up"
app:navigationIcon="?attr/homeAsUpIndicator"
app:title="@string/stories_completed"
app:title="@string/completed_story_list_activity_title"
app:titleTextAppearance="@style/ToolbarTextAppearance"
app:titleTextColor="@color/white" />
</com.google.android.material.appbar.AppBarLayout>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@
<string name="topic_in_progress">Topic in Progress</string>
<string name="stories_completed">Stories Completed</string>
<string name="story_completed">Story Completed</string>
<!-- CompletedStoryListActivity -->
<string name="completed_story_list_activity_title">Stories Completed</string>
<!-- WalkthroughActivity -->
<string name="walkthrough_welcome_description">Learn new math skills with stories that show you how to use them in your daily life</string>
<string name="welcome">"Welcome %s!"</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import com.google.common.truth.Truth.assertThat
import dagger.Component
import org.hamcrest.CoreMatchers.containsString
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.R
Expand Down Expand Up @@ -91,6 +94,13 @@ class CompletedStoryListActivityTest {
private val internalProfileId = 0
private val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build()

@get:Rule
val activityTestRule = ActivityTestRule(
CompletedStoryListActivity::class.java,
/* initialTouchMode= */ true,
/* launchActivity= */ false
)

@Inject
lateinit var testCoroutineDispatchers: TestCoroutineDispatchers

Expand Down Expand Up @@ -130,6 +140,16 @@ class CompletedStoryListActivityTest {
ApplicationProvider.getApplicationContext<TestApplication>().inject(this)
}

@Test
fun testCompletedStoryList_hasCorrectActivityLabel() {
activityTestRule.launchActivity(createCompletedStoryListActivityIntent(internalProfileId))
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.completed_story_list_activity_title))
}

@Test
fun testCompletedStoryList_checkItem0_storyThumbnailDescriptionIsCorrect() {
launch<CompletedStoryListActivity>(
Expand Down

0 comments on commit fe5bc07

Please sign in to comment.