Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2785 & Fixes part of #2743: A11y activity label added #2783

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
<meta-data android:name="expiration_date" android:value="2020-09-01" />
<activity
android:name=".app.administratorcontrols.AdministratorControlsActivity"
android:label="@string/administrator_controls_activity_label"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.administratorcontrols.appversion.AppVersionActivity"
android:label="@string/app_version_activity_label"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.completedstorylist.CompletedStoryListActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class AdministratorControlsActivity :
PROFILE_LIST_FRAGMENT
}
administratorControlsActivityPresenter.handleOnCreate(extraControlsTitle, lastLoadedFragment)
title = getString(R.string.administrator_controls)
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout-land/app_version_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".administratorcontrols.appversion.AppVersionActivity">
tools:context=".app.administratorcontrols.appversion.AppVersionActivity">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_version_app_bar_layout"
Expand All @@ -23,7 +23,7 @@
app:navigationContentDescription="@string/navigate_up"
app:navigationIcon="?attr/homeAsUpIndicator"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:title="@string/administrator_controls_app_version"
app:title="@string/app_version_activity_label"
app:titleTextAppearance="@style/ToolbarTextAppearance"
app:titleTextColor="@color/white" />
</com.google.android.material.appbar.AppBarLayout>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/app_version_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
app:navigationContentDescription="@string/navigate_up"
app:navigationIcon="?attr/homeAsUpIndicator"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:title="@string/administrator_controls_app_version"
app:title="@string/app_version_activity_label"
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 @@ -8,6 +8,7 @@
<string name="menu_help">Help</string>
<string name="menu_switch_profile">Switch Profile</string>
<string name="administrator_controls">Administrator Controls</string>
<string name="administrator_controls_activity_label">Administrator Controls</string>
<string name="drawer_open_content_description">Navigation Menu Open</string>
<string name="drawer_close_content_description">Navigation Menu Close</string>
<string name="welcome_text">Welcome to Oppia!</string>
Expand Down Expand Up @@ -329,6 +330,7 @@
<string name="log_out_dialog_okay_button">Ok</string>
<string name="log_out_dialog_message">Are you sure you want to log out of your profile?</string>
<!-- AppVersionFragment -->
<string name="app_version_activity_label">App Version</string>
<string name="app_version_name">App Version %s</string>
<string name="app_last_update_date">The last update was installed on %s. Use the above version number to send feedback about bugs.</string>
<!-- OptionsActivity -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.espresso.util.HumanReadables
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.Matchers
import org.hamcrest.Matchers.not
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 @@ -103,6 +106,13 @@ import javax.inject.Singleton
)
class AdministratorControlsActivityTest {

@get:Rule
val activityTestRule: ActivityTestRule<AdministratorControlsActivity> = ActivityTestRule(
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
AdministratorControlsActivity::class.java,
/* initialTouchMode= */ true,
/* launchActivity= */ false
)

@Inject
lateinit var profileTestHelper: ProfileTestHelper

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

@Test
fun testAdministratorControlsActivity_hasCorrectActivityLabel() {
activityTestRule.launchActivity(createAdministratorControlsActivityIntent(profileId = 0))
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.administrator_controls_activity_label))
}

@Test
fun testAdministratorControlsFragment_generalAndProfileManagementIsDisplayed() {
launch<AdministratorControlsActivity>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,22 @@ import android.app.Application
import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import androidx.test.core.app.ActivityScenario
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.pressBack
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.Intents.intended
import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isRoot
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.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 @@ -85,6 +82,11 @@ import javax.inject.Singleton
)
class AppVersionActivityTest {

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

@Inject
lateinit var context: Context
rt4914 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -114,6 +116,16 @@ class AppVersionActivityTest {
ApplicationProvider.getApplicationContext<TestApplication>().inject(this)
}

@Test
fun testAppVersionActivity_hasCorrectActivityLabel() {
activityTestRule.launchActivity(createAppVersionActivityIntent())
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.app_version_activity_label))
}

@Test
fun testAppVersionActivity_loadFragment_displaysAppVersion() {
launchAppVersionActivityIntent().use {
Expand Down Expand Up @@ -173,26 +185,6 @@ class AppVersionActivityTest {
}
}

@Test
fun testAppVersionActivity_loadFragment_onBackPressed_displaysAdministratorControlsActivity() {
ActivityScenario.launch<AdministratorControlsActivity>(
launchAdministratorControlsActivityIntent(
0
)
).use {
testCoroutineDispatchers.runCurrent()
onView(withId(R.id.administrator_controls_list)).perform(
scrollToPosition<RecyclerView.ViewHolder>(
3
)
)
onView(withText(R.string.administrator_controls_app_version)).perform(click())
intended(hasComponent(AppVersionActivity::class.java.name))
onView(isRoot()).perform(pressBack())
onView(withId(R.id.administrator_controls_list)).check(matches(isDisplayed()))
}
}

private fun getDateTime(dateTimeTimestamp: Long): String? {
return oppiaDateTimeFormatter.formatDateFromDateString(
OppiaDateTimeFormatter.DD_MMM_YYYY,
Expand All @@ -202,16 +194,12 @@ class AppVersionActivityTest {
}

private fun launchAppVersionActivityIntent(): ActivityScenario<AppVersionActivity> {
val intent = AppVersionActivity.createAppVersionActivityIntent(
ApplicationProvider.getApplicationContext()
)
return ActivityScenario.launch(intent)
return ActivityScenario.launch(createAppVersionActivityIntent())
}

private fun launchAdministratorControlsActivityIntent(profileId: Int): Intent {
return AdministratorControlsActivity.createAdministratorControlsActivityIntent(
ApplicationProvider.getApplicationContext(),
profileId
private fun createAppVersionActivityIntent(): Intent {
return AppVersionActivity.createAppVersionActivityIntent(
ApplicationProvider.getApplicationContext()
)
}

Expand Down