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

Fix #2815 : Add label for AdminPinActivity #2922

Merged
merged 11 commits into from
Mar 23, 2021
Merged
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".app.profile.AdminPinActivity"
android:label="@string/admin_pin_activity_title"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".app.profile.PinPasswordActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class AdminPinActivityPresenter @Inject constructor(

/** Binds ViewModel and sets up text and button listeners. */
fun handleOnCreate() {
activity.title = activity.getString(R.string.add_profile_title)
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
activity.supportActionBar?.setDisplayHomeAsUpEnabled(true)
activity.supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_close_white_24dp)
activity.supportActionBar?.setHomeActionContentDescription(R.string.admin_auth_close)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
<string name="admin_pin_error_pin_length">Your PIN should be 5 digits long.</string>
<string name="admin_pin_error_pin_confirm_wrong">Please make sure that both PINs match.</string>
<string name="save">Save</string>
<string name="admin_pin_activity_title">Authorise to add profiles</string>
starboi02 marked this conversation as resolved.
Show resolved Hide resolved
<!-- AddProfileActivity -->
<string name="add_profile_title">Add Profile</string>
<string name="add_profile_input_name">Name*</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.util.HumanReadables
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import com.google.android.material.textfield.TextInputLayout
import com.google.common.truth.Truth.assertThat
import dagger.Component
import org.hamcrest.Description
import org.hamcrest.Matcher
Expand All @@ -40,6 +42,7 @@ import org.hamcrest.Matchers.not
import org.hamcrest.TypeSafeMatcher
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 @@ -99,6 +102,11 @@ import javax.inject.Singleton
)
class AdminPinActivityTest {

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

@Inject
lateinit var context: Context

Expand All @@ -125,6 +133,23 @@ class AdminPinActivityTest {
Intents.release()
}

@Test
fun testAdminPinActivity_hasCorrectActivityLabel() {
activityTestRule.launchActivity(
AdminPinActivity.createAdminPinActivityIntent(
context = context,
profileId = 0,
colorRgb = -10710042,
adminPinEnum = 0
)
)
val title = activityTestRule.activity.title
BenHenning marked this conversation as resolved.
Show resolved Hide resolved

// 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.admin_pin_activity_title))
}

@Test
fun testAdminPinActivity_inputPin_submit_opensAddProfileActivity() {
launch<AdminPinActivity>(
Expand Down