From 415f08bdd7f88ee1c70c7d03819f25e6e5af591e Mon Sep 17 00:00:00 2001 From: Deon Olarewaju Date: Sun, 4 Feb 2024 13:34:54 +0100 Subject: [PATCH 1/4] split test method into 4 versions, ensuring tests pass for mobile[portrait, landscape] and tablets[portrait, landscape]. --- .../android/app/home/HomeActivityTest.kt | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) 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..661d32ab65a 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_mobilePortraitDisplaysAllTopicCardsIn2Columns() { fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markAllTopicsAsCompleted( profileId = profileId, @@ -1352,6 +1353,58 @@ class HomeActivityTest { } } + @Config(qualifiers = "+land") + @Test + fun testHomeActivity_allTopicsCompleted_mobileLandscapeDisplaysAllTopicCardsIn3Columns() { + fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) + storyProgressTestHelper.markAllTopicsAsCompleted( + profileId = profileId, + timestampOlderThanOneWeek = false + ) + logIntoAdminTwice() + launch(createHomeActivityIntent(internalProfileId)).use { + testCoroutineDispatchers.runCurrent() + scrollToPosition(position = 3) + if (context.resources.getBoolean(R.bool.isTablet)) { + verifyHomeRecyclerViewHasGridColumnCount(columnCount = 4) + } else { + verifyHomeRecyclerViewHasGridColumnCount(columnCount = 3) + } + } + } + + @Config(qualifiers = "+sw600dp-port") + @Test + fun testHomeActivity_allTopicsCompleted_tabletPortraitDisplaysAllTopicCardsIn3Columns() { + 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_tabletLandscapeDisplaysAllTopicCardsIn4Columns() { + 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) + } + } + @Test fun testHomeActivity_noTopicsCompleted_displaysAllTopicsHeader() { // Only new users will have no progress for any topics. From d365c4824ab1763157ea57d90f544d0306a7898b Mon Sep 17 00:00:00 2001 From: Deon Olarewaju Date: Sun, 4 Feb 2024 14:34:11 +0100 Subject: [PATCH 2/4] corrected indentation --- .../java/org/oppia/android/app/home/HomeActivityTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 661d32ab65a..887d5f6cad1 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,7 +1333,7 @@ class HomeActivityTest { } } - @Config(qualifiers = "+port") + @Config(qualifiers = "+port") @Test fun testHomeActivity_allTopicsCompleted_mobilePortraitDisplaysAllTopicCardsIn2Columns() { fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) From 7657baa94986da79a3abbcb8e9eb8140dd72ddac Mon Sep 17 00:00:00 2001 From: Deon Olarewaju Date: Tue, 6 Feb 2024 17:59:53 +0100 Subject: [PATCH 3/4] removed unnecessary if condition in tests. --- .../org/oppia/android/app/home/HomeActivityTest.kt | 12 ++---------- 1 file changed, 2 insertions(+), 10 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 887d5f6cad1..3a35e912329 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 @@ -1345,11 +1345,7 @@ 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) } } @@ -1365,11 +1361,7 @@ class HomeActivityTest { launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() scrollToPosition(position = 3) - if (context.resources.getBoolean(R.bool.isTablet)) { - verifyHomeRecyclerViewHasGridColumnCount(columnCount = 4) - } else { - verifyHomeRecyclerViewHasGridColumnCount(columnCount = 3) - } + verifyHomeRecyclerViewHasGridColumnCount(columnCount = 3) } } From 788c9af8030fa6dc229915b89512048010f7d506 Mon Sep 17 00:00:00 2001 From: Deon Olarewaju Date: Wed, 7 Feb 2024 12:48:34 +0100 Subject: [PATCH 4/4] renamed test with suggestions --- .../java/org/oppia/android/app/home/HomeActivityTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 3a35e912329..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 @@ -1335,7 +1335,7 @@ class HomeActivityTest { @Config(qualifiers = "+port") @Test - fun testHomeActivity_allTopicsCompleted_mobilePortraitDisplaysAllTopicCardsIn2Columns() { + fun testHomeActivity_allTopicsCompleted_mobilePortrait_displaysAllTopicCardsIn2Columns() { fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markAllTopicsAsCompleted( profileId = profileId, @@ -1351,7 +1351,7 @@ class HomeActivityTest { @Config(qualifiers = "+land") @Test - fun testHomeActivity_allTopicsCompleted_mobileLandscapeDisplaysAllTopicCardsIn3Columns() { + fun testHomeActivity_allTopicsCompleted_mobileLandscape_displaysAllTopicCardsIn3Columns() { fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markAllTopicsAsCompleted( profileId = profileId, @@ -1367,7 +1367,7 @@ class HomeActivityTest { @Config(qualifiers = "+sw600dp-port") @Test - fun testHomeActivity_allTopicsCompleted_tabletPortraitDisplaysAllTopicCardsIn3Columns() { + fun testHomeActivity_allTopicsCompleted_tabletPortrait_displaysAllTopicCardsIn3Columns() { fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markAllTopicsAsCompleted( profileId = profileId, @@ -1383,7 +1383,7 @@ class HomeActivityTest { @Config(qualifiers = "+sw600dp-land") @Test - fun testHomeActivity_allTopicsCompleted_tabletLandscapeDisplaysAllTopicCardsIn4Columns() { + fun testHomeActivity_allTopicsCompleted_tabletLandscape_displaysAllTopicCardsIn4Columns() { fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markAllTopicsAsCompleted( profileId = profileId,