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 part of #3602: Add label for all non-test activities for Profile Edit Activity #4783

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
783b29b
added label to profile edit activity
deonwaju Dec 8, 2022
3832b7d
added label to profile edit activity
deonwaju Dec 9, 2022
ac21080
added label to profile edit activity
deonwaju Dec 9, 2022
7efd9bb
added label to profile edit activity
deonwaju Dec 9, 2022
5e2f6b6
Merge branch 'develop' into add-label-to-profile-edit-activity
deonwaju Dec 9, 2022
40d5aca
added changes from review
deonwaju Dec 9, 2022
f9a06dd
Merge remote-tracking branch 'origin/add-label-to-profile-edit-activi…
deonwaju Dec 9, 2022
06acd7c
removed model/build.gradle from being tracked
deonwaju Dec 10, 2022
3918851
removed .gitignore from being tracked
deonwaju Dec 10, 2022
f24589c
added back .gitignore and model/build.gradle files i untracked, after…
deonwaju Dec 10, 2022
b7ea5e5
removed strings in other languages except english, added test like in…
deonwaju Dec 13, 2022
6a9f3fa
removed strings in other languages except english, added test like in…
deonwaju Dec 13, 2022
433c4e6
Fixes #4712: Ensure CoordinatorLayout Behaviors are not renamed/remov…
BenHenning Nov 17, 2022
0483a72
Localisation updates from https://translatewiki.net. (#4733)
translatewiki Nov 17, 2022
7634f1e
Fix #4645: "Continue Studying" texts keeps showing even when there is…
JishnuGoyal Nov 17, 2022
e7d5fcb
Fix #4709: Revert "Fix #2581: Marquee auto restart issue (#4392)" (#4…
BenHenning Nov 18, 2022
ff10c4f
Update version codes to prepare for RC02 of Beta MR2 (#4745)
BenHenning Nov 18, 2022
b1e1bcc
Fix #4746: Update app to target SDK 31 (#4747)
BenHenning Nov 19, 2022
b5f3ab3
Fix #4445: Add scaling animation for Continue button (#4568)
JishnuGoyal Nov 19, 2022
62fb0e3
Localisation updates from https://translatewiki.net. (#4753)
translatewiki Nov 21, 2022
3896d85
Fix #2546: Rename OngoingStory to PromotedStory (#4704)
adhiamboperes Nov 21, 2022
fa39d88
fixed merge conflict
deonwaju Jan 9, 2023
d54fe33
Fix #4750: Fixes SDK 31 support (#4752)
BenHenning Nov 23, 2022
1b9bb14
Fix #4756: Add support for logging an invested engagement event (#4757)
BenHenning Nov 23, 2022
5d789ee
Fix #4764: Spotlight overlays have some UI issues (#4763)
JishnuGoyal Nov 27, 2022
6f8757a
Localisation updates from https://translatewiki.net. (#4761)
translatewiki Nov 29, 2022
df1cf78
Fixed Hints & Solution and Concept Card Dark Mode (#4779)
MohitGupta121 Dec 6, 2022
cbb4606
Fix #4775: SpotlightFragmentTest is very flaky (#4780)
JishnuGoyal Dec 9, 2022
27801bc
removed model/build.gradle from being tracked
deonwaju Dec 10, 2022
99905f4
removed .gitignore from being tracked
deonwaju Dec 10, 2022
db2f602
added back .gitignore and model/build.gradle files i untracked, after…
deonwaju Dec 10, 2022
83cf1e5
removed strings in other languages except english, added test like in…
deonwaju Dec 13, 2022
1c96913
Merge branch 'add-label-to-profile-edit-activity' of https://github.c…
deonwaju Jan 9, 2023
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
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.settings.profile.ProfileEditActivity"
android:label="@string/profile_edit_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.settings.profile.ProfileListActivity"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -583,5 +583,6 @@
<string name="profile_edit_fragment_test_activity_label">Profile Edit Fragment Test Activity</string>
<string name="administrator_controls_fragment_test_activity_label">Administrator Controls Fragment Test Activity</string>
<string name="revision_navigation_cards_header">Continue Studying</string>
<string name="profile_edit_activity_title">Profile Edit</string>
<string name="state_fragment_hint_bar_forced_announcement_text">Go to the bottom of the screen for a hint.</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
package org.oppia.android.app.options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deonwaju I think there is no need of commiting this file.
I'm right @rt4914 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, Thought @rt4914 said write tests like Please add test similar to in ProfileEditActivity.

Copy link
Member

@MohitGupta121 MohitGupta121 Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay @deonwaju Thanks for clearing. Yes then we need this file.


import android.app.Application
import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import androidx.test.core.app.ApplicationProvider
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.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.app.model.ReadingTextSize.MEDIUM_TEXT_SIZE
import org.oppia.android.app.model.ScreenName
import org.oppia.android.data.backends.gae.NetworkConfigProdModule
import org.oppia.android.data.backends.gae.NetworkModule
import org.oppia.android.domain.classify.InteractionsModule
import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule
import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule
import org.oppia.android.domain.classify.rules.dragAndDropSortInput.DragDropSortInputModule
import org.oppia.android.domain.classify.rules.fractioninput.FractionInputModule
import org.oppia.android.domain.classify.rules.imageClickInput.ImageClickInputModule
import org.oppia.android.domain.classify.rules.itemselectioninput.ItemSelectionInputModule
import org.oppia.android.domain.classify.rules.mathequationinput.MathEquationInputModule
import org.oppia.android.domain.classify.rules.multiplechoiceinput.MultipleChoiceInputModule
import org.oppia.android.domain.classify.rules.numberwithunits.NumberWithUnitsRuleModule
import org.oppia.android.domain.classify.rules.numericexpressioninput.NumericExpressionInputModule
import org.oppia.android.domain.classify.rules.numericinput.NumericInputRuleModule
import org.oppia.android.domain.classify.rules.ratioinput.RatioInputModule
import org.oppia.android.domain.classify.rules.textinput.TextInputRuleModule
import org.oppia.android.domain.exploration.ExplorationStorageModule
import org.oppia.android.domain.hintsandsolution.HintsAndSolutionConfigModule
import org.oppia.android.domain.hintsandsolution.HintsAndSolutionProdModule
import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule
import org.oppia.android.domain.oppialogger.LogStorageModule
import org.oppia.android.domain.oppialogger.LoggingIdentifierModule
import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule
import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule
import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule
import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule
import org.oppia.android.domain.platformparameter.PlatformParameterModule
import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule
import org.oppia.android.testing.OppiaTestRule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.junit.InitializeDefaultLocaleRule
import org.oppia.android.testing.robolectric.RobolectricModule
import org.oppia.android.testing.threading.TestDispatcherModule
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.AssetModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.locale.LocaleProdModule
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.extractCurrentAppScreenName
import org.oppia.android.util.logging.EventLoggingConfigurationModule
import org.oppia.android.util.logging.LoggerModule
import org.oppia.android.util.logging.SyncStatusModule
import org.oppia.android.util.logging.firebase.FirebaseLogUploaderModule
import org.oppia.android.util.networking.NetworkConnectionDebugUtilModule
import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule
import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule
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 [ProfileEditActivityTest]. */
@RunWith(AndroidJUnit4::class)
@LooperMode(LooperMode.Mode.PAUSED)
@Config(
application = ProfileEditActivityTest.TestApplication::class,
qualifiers = "port-xxhdpi"
)
class ProfileEditActivityTest {
@get:Rule
val initializeDefaultLocaleRule = InitializeDefaultLocaleRule()

@get:Rule
val oppiaTestRule = OppiaTestRule()

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

@Inject lateinit var context: Context

@Before
fun setUp() {
setUpTestApplicationComponent()
}

private fun setUpTestApplicationComponent() {
ApplicationProvider.getApplicationContext<TestApplication>().inject(this)
}

@Test
fun testActivity_createIntent_verifyScreenNameInIntent() {
val screenName = createProfileEditActivityTestIntent().extractCurrentAppScreenName()

assertThat(screenName).isEqualTo(ScreenName.READING_TEXT_SIZE_ACTIVITY)
}

@Test
fun testProfileEditActivityTest_hasCorrectActivityLabel() {
activityTestRule.launchActivity(createProfileEditActivityTestIntent())

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.reading_text_size_activity_title))
}

private fun createProfileEditActivityTestIntent() =
ProfileEditActivityTest.createProfileEditActivityTestIntent(context, MEDIUM_TEXT_SIZE)

// TODO(#59): Figure out a way to reuse modules instead of needing to re-declare them.
@Singleton
@Component(
modules = [
RobolectricModule::class,
PlatformParameterModule::class, PlatformParameterSingletonModule::class,
TestDispatcherModule::class, ApplicationModule::class,
LoggerModule::class, ContinueModule::class, FractionInputModule::class,
ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class,
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class, WorkManagerConfigurationModule::class,
ApplicationStartupListenerModule::class, LogReportWorkerModule::class,
HintsAndSolutionConfigModule::class, HintsAndSolutionProdModule::class,
FirebaseLogUploaderModule::class, FakeOppiaClockModule::class,
DeveloperOptionsStarterModule::class, DeveloperOptionsModule::class,
ExplorationStorageModule::class, NetworkModule::class, NetworkConfigProdModule::class,
NetworkConnectionUtilDebugModule::class, NetworkConnectionDebugUtilModule::class,
AssetModule::class, LocaleProdModule::class, ActivityRecreatorTestModule::class,
NumericExpressionInputModule::class, AlgebraicExpressionInputModule::class,
MathEquationInputModule::class, SplitScreenInteractionModule::class,
LoggingIdentifierModule::class, ApplicationLifecycleModule::class,
SyncStatusModule::class, MetricLogSchedulerModule::class, TestingBuildFlavorModule::class,
EventLoggingConfigurationModule::class, ActivityRouterModule::class,
CpuPerformanceSnapshotterModule::class
]
)
interface TestApplicationComponent : ApplicationComponent {
@Component.Builder
interface Builder : ApplicationComponent.Builder

fun inject(profileEditActivityTest: ProfileEditActivityTest)
}

class TestApplication : Application(), ActivityComponentFactory, ApplicationInjectorProvider {
private val component: TestApplicationComponent by lazy {
DaggerProfileEditActivityTest_TestApplicationComponent.builder()
.setApplication(this)
.build() as TestApplicationComponent
}

fun inject(profileEditActivityTest: ProfileEditActivityTest) {
component.inject(profileEditActivityTest)
}

override fun createActivityComponent(activity: AppCompatActivity): ActivityComponent {
return component.getActivityComponentBuilderProvider().get().setActivity(activity).build()
}

override fun getApplicationInjector(): ApplicationInjector = component
}
}