From 1295328da0d3f8b275cbdf9120aca1b3d005bf5b Mon Sep 17 00:00:00 2001 From: Deon Olarewaju Date: Thu, 8 Feb 2024 08:52:42 +0100 Subject: [PATCH] Fix #2587: testHomeActivity_allTopicsCompleted_displaysAllTopicCards() test not working (#5330) ## Explanation Fix for #2587: split test method into 4 versions, [mobilePortrait, mobileLandscape, tabletPortrait, tabletLandscape] A. Mobile potrait test mobile-port B. Mobile Lanscape mobile-landscape C. Tablet Portrait tablet-port D. Tablet Landscape test. tablet-land ## Essential Checklist - [X] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [X] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [X] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [X] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [X] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [X] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). --- .../android/app/home/HomeActivityTest.kt | 57 +++++++++++++++++-- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt index f5e058dfb62..771d5456801 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt @@ -1333,8 +1333,9 @@ class HomeActivityTest { } } + @Config(qualifiers = "+port") @Test - fun testHomeActivity_allTopicsCompleted_displaysAllTopicCards() { + fun testHomeActivity_allTopicsCompleted_mobilePortrait_displaysAllTopicCardsIn2Columns() { fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markAllTopicsAsCompleted( profileId = profileId, @@ -1344,11 +1345,55 @@ class HomeActivityTest { launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() scrollToPosition(position = 3) - if (context.resources.getBoolean(R.bool.isTablet)) { - verifyHomeRecyclerViewHasGridColumnCount(columnCount = 3) - } else { - verifyHomeRecyclerViewHasGridColumnCount(columnCount = 2) - } + verifyHomeRecyclerViewHasGridColumnCount(columnCount = 2) + } + } + + @Config(qualifiers = "+land") + @Test + fun testHomeActivity_allTopicsCompleted_mobileLandscape_displaysAllTopicCardsIn3Columns() { + fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) + storyProgressTestHelper.markAllTopicsAsCompleted( + profileId = profileId, + timestampOlderThanOneWeek = false + ) + logIntoAdminTwice() + launch(createHomeActivityIntent(internalProfileId)).use { + testCoroutineDispatchers.runCurrent() + scrollToPosition(position = 3) + verifyHomeRecyclerViewHasGridColumnCount(columnCount = 3) + } + } + + @Config(qualifiers = "+sw600dp-port") + @Test + fun testHomeActivity_allTopicsCompleted_tabletPortrait_displaysAllTopicCardsIn3Columns() { + fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) + storyProgressTestHelper.markAllTopicsAsCompleted( + profileId = profileId, + timestampOlderThanOneWeek = false + ) + logIntoAdminTwice() + launch(createHomeActivityIntent(internalProfileId)).use { + testCoroutineDispatchers.runCurrent() + scrollToPosition(position = 3) + verifyHomeRecyclerViewHasGridColumnCount(columnCount = 3) + } + } + + @Config(qualifiers = "+sw600dp-land") + @Test + fun testHomeActivity_allTopicsCompleted_tabletLandscape_displaysAllTopicCardsIn4Columns() { + fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) + storyProgressTestHelper.markAllTopicsAsCompleted( + profileId = profileId, + timestampOlderThanOneWeek = false + ) + logIntoAdminTwice() + launch(createHomeActivityIntent(internalProfileId)).use { + testCoroutineDispatchers.runCurrent() + scrollToPosition(position = 3) + verifyHomeRecyclerViewHasGridColumnCount(columnCount = 4) } }