diff --git a/app/src/main/java/org/oppia/android/app/activity/route/ActivityRouter.kt b/app/src/main/java/org/oppia/android/app/activity/route/ActivityRouter.kt index 495d455f574..97f603cc8fb 100644 --- a/app/src/main/java/org/oppia/android/app/activity/route/ActivityRouter.kt +++ b/app/src/main/java/org/oppia/android/app/activity/route/ActivityRouter.kt @@ -18,19 +18,21 @@ class ActivityRouter @Inject constructor( /** Opens the activity corresponding to the specified [destinationScreen]. */ fun routeToScreen(destinationScreen: DestinationScreen) { destinationRoutes[destinationScreen.destinationScreenCase]?.let { route -> - when (destinationScreen.destinationScreenCase) { - DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_PARAMS -> { - activity.startActivity( - route.createIntent( - activity, - destinationScreen - ) + if (destinationScreen.destinationScreenCase == + DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_PARAMS + ) { + activity.startActivity( + route.createIntent( + activity, + destinationScreen ) - } - DestinationScreenCase.DESTINATIONSCREEN_NOT_SET, null -> { - consoleLogger.w("ActivityRouter", "Destination screen case is not identified.") - } + ) } } + if (destinationScreen.destinationScreenCase == + DestinationScreenCase.DESTINATIONSCREEN_NOT_SET + ) { + consoleLogger.w("ActivityRouter", "Destination screen case is not identified.") + } } } diff --git a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt index 165b651709f..45a44b7f37e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt @@ -658,7 +658,7 @@ class ProfileProgressFragmentTest { } @Test - fun testProfileProgressFragment_clickViewAll_opensRecentlyPlayedActivity() { + fun testClickViewAll_withLessThanTwoStories_opensRecentlyPlayedActivityWithStoriesForYouTitle() { storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), timestampOlderThanOneWeek = false @@ -685,6 +685,42 @@ class ProfileProgressFragmentTest { } } + @Test + fun testClickViewAll_opensRecentlyPlayedActivityWithRecentlyPlayedActivityTitle() { + storyProgressTestHelper.markCompletedFractionsStory0( + profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + timestampOlderThanOneWeek = false + ) + storyProgressTestHelper.markCompletedRatiosStory0( + profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + timestampOlderThanOneWeek = false + ) + storyProgressTestHelper.markInProgressNotSavedTestTopic0Story0( + profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + timestampOlderThanOneWeek = false + ) + launch(createProfileProgressActivityIntent(internalProfileId)).use { + testCoroutineDispatchers.runCurrent() + verifyItemDisplayedOnProfileProgressListItem( + itemPosition = 0, + targetViewId = R.id.view_all_text_view, + stringToMatch = "View All" + ) + val recentlyPlayedActivityParams = RecentlyPlayedActivityParams + .newBuilder() + .setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build()) + .setActivityTitle(RecentlyPlayedActivityTitle.RECENTLY_PLAYED_STORIES) + .build() + clickProfileProgressItem(itemPosition = 0, targetViewId = R.id.view_all_text_view) + intended( + allOf( + hasProtoExtra(RECENTLY_PLAYED_ACTIVITY_INTENT_EXTRAS_KEY, recentlyPlayedActivityParams), + hasComponent(RecentlyPlayedActivity::class.java.name) + ) + ) + } + } + @Test fun testProfileProgressFragment_noProgress_topicCountIsNotClickable() { launch(createProfileProgressActivityIntent(internalProfileId)).use { diff --git a/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt b/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt index a51cdb2ea04..418d633c793 100644 --- a/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt +++ b/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt @@ -116,9 +116,7 @@ class ActivityRouterModuleTest { @Test fun testInjectDestinationRoutes_hasRouteForRecentlyPlayedActivity() { - assertThat( - destinationRoutes.containsKey(DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_PARAMS) - ).isTrue() + assertThat(destinationRoutes).containsKey(DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_PARAMS) val route = destinationRoutes[DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_PARAMS] val intent = route?.createIntent(context, DestinationScreen.getDefaultInstance()) assertThat(intent).hasComponentClass(RecentlyPlayedActivity::class.java)