From 87a7acc3063457d54477e1c950692ec55fecd112 Mon Sep 17 00:00:00 2001 From: priyatanu Date: Sat, 8 Jan 2022 12:29:11 +0530 Subject: [PATCH] Fix part of #3602: Add label for Walk Through Activity (#3983) * Add lable for Wal Through Activity * Add Test WalkthroughActivityLabelTest for adding label to Activity * Remove WalkthroughActivityLabelTest and add the test case in WalkthroughActivityTest * Fix failing accessibiltiy failure and clean up acivity scenario * Add new Line to proto file * Fix Test Cases for Walk Through label change --- app/src/main/AndroidManifest.xml | 1 + app/src/main/res/values/strings.xml | 1 + .../walkthrough/WalkthroughActivityTest.kt | 26 +++++++++++++++++++ .../accessibility_label_exemptions.textproto | 1 - 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3ade708d1f0..c4f2b1c72fb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -216,6 +216,7 @@ android:theme="@style/OppiaThemeWithoutActionBar" /> Stories Completed + App walkthrough Learn new math skills with stories that show you how to use them in your daily life "Welcome %s!" diff --git a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughActivityTest.kt index 9f4fcfa2482..a858db908a0 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughActivityTest.kt @@ -1,8 +1,10 @@ package org.oppia.android.app.walkthrough import android.app.Application +import android.content.Context import androidx.appcompat.app.AppCompatActivity import androidx.test.core.app.ActivityScenario.launch +import androidx.test.core.app.ApplicationProvider import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.pressBack import androidx.test.espresso.action.ViewActions.click @@ -14,8 +16,10 @@ 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 com.google.common.truth.Truth.assertThat import dagger.Component import org.hamcrest.CoreMatchers.allOf +import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -77,6 +81,7 @@ import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode +import javax.inject.Inject import javax.inject.Singleton /** Tests for [WalkthroughActivity]. */ @@ -90,8 +95,19 @@ class WalkthroughActivityTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() + @Inject + lateinit var context: Context // TODO(#3367): Use AccessibilityTestRule + @Before + fun setUp() { + setUpTestApplicationComponent() + } + + private fun setUpTestApplicationComponent() { + ApplicationProvider.getApplicationContext().inject(this) + } + @Test fun testWalkthroughActivity_defaultProgressWorksCorrectly() { launch(WalkthroughActivity::class.java).use { @@ -173,6 +189,16 @@ class WalkthroughActivityTest { } } + @Test + fun testWalkthroughActivity_hasCorrectActivityLabel() { + launch(WalkthroughActivity::class.java).use { scenario -> + scenario.onActivity { activity -> + val title = activity.title + assertThat(title).isEqualTo(context.getString(R.string.walkthrough_activity_title)) + } + } + } + // TODO(#59): Figure out a way to reuse modules instead of needing to re-declare them. @Singleton @Component( diff --git a/scripts/assets/accessibility_label_exemptions.textproto b/scripts/assets/accessibility_label_exemptions.textproto index d52830ffe26..913aa934fa5 100644 --- a/scripts/assets/accessibility_label_exemptions.textproto +++ b/scripts/assets/accessibility_label_exemptions.textproto @@ -33,4 +33,3 @@ exempted_activity: "app/src/main/java/org/oppia/android/app/testing/TopicTestAct exempted_activity: "app/src/main/java/org/oppia/android/app/testing/TopicTestActivityForStory" exempted_activity: "app/src/main/java/org/oppia/android/app/testing/ViewBindingAdaptersTestActivity" exempted_activity: "app/src/main/java/org/oppia/android/app/testing/activity/TestActivity" -exempted_activity: "app/src/main/java/org/oppia/android/app/walkthrough/WalkthroughActivity"