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_label"
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".app.profile.PinPasswordActivity"
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_label">Authorise to add profiles</string>
<!-- 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 @@ -2,6 +2,7 @@ package org.oppia.android.app.profile

import android.app.Application
import android.content.Context
import android.content.Intent
import android.view.View
import android.view.ViewParent
import android.widget.FrameLayout
Expand Down Expand Up @@ -30,7 +31,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 +43,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 +103,11 @@ import javax.inject.Singleton
)
class AdminPinActivityTest {

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

@Inject
lateinit var context: Context

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

@Test
fun testAdminPinActivity_hasCorrectActivityLabel(){
activityTestRule.launchActivity(createAdminPinActivityIntent())
val title =activityTestRule.activity.title
rt4914 marked this conversation as resolved.
Show resolved Hide resolved

assertThat(title).isEqualTo(context.getString(R.string.admin_pin_activity_label))
}

@Test
fun testAdminPinActivity_inputPin_submit_opensAddProfileActivity() {
launch<AdminPinActivity>(
Expand Down Expand Up @@ -1011,6 +1028,12 @@ class AdminPinActivityTest {
ApplicationProvider.getApplicationContext<TestApplication>().inject(this)
}

private fun createAdminPinActivityIntent(): Intent {
return AdminPinActivity.createAdminPinActivityIntent(
ApplicationProvider.getApplicationContext(),0,-10710042,0
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
)
}

private fun hasErrorText(@StringRes expectedErrorTextId: Int): Matcher<View> {
return object : TypeSafeMatcher<View>() {
override fun matchesSafely(view: View): Boolean {
Expand Down