diff --git a/.github/workflows/test-android-e2e.yml b/.github/workflows/test-android-e2e.yml index 892a7241..e997d7ad 100644 --- a/.github/workflows/test-android-e2e.yml +++ b/.github/workflows/test-android-e2e.yml @@ -1,6 +1,8 @@ name: Run E2E Tests for Android on: workflow_dispatch: + pull_request: + branches: [ main ] jobs: test-android: name: Test Android @@ -45,9 +47,12 @@ jobs: disable-animations: true profile: Nexus 6 script: | - adb emu geo fix 72.58727 23.02579 + adb emu geo fix 72.5228 23.0127 ./gradlew app:connectedDebugAndroidTest -i -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.DefaultConnectionFlowSuite ./gradlew app:connectedDebugAndroidTest -i -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.DefaultConnectionFlowSuite2 + ./gradlew app:connectedDebugAndroidTest -i -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.main.SimulationStartTrackingHistoryLoggedTest + ./gradlew app:connectedDebugAndroidTest -i -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.main.SimulationStopTrackingHistoryLoggedTest + ./gradlew app:connectedDebugAndroidTest -i -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.DefaultConnectionFlowSuite3 ./gradlew app:connectedDebugAndroidTest -i -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.AWSConnectionSuite ./gradlew app:connectedDebugAndroidTest -i -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.AWSSignInSuite ./gradlew app:connectedDebugAndroidTest -i -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.main.TrackingStartTrackingTest diff --git a/README.md b/README.md index 28318b7c..6a1550d8 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,9 @@ Note: ./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.DefaultConnectionFlowSuite ./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.DefaultConnectionFlowSuite2 + ./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.main.SimulationStartTrackingHistoryLoggedTest + ./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.main.SimulationStopTrackingHistoryLoggedTest + ./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.DefaultConnectionFlowSuite3 ./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.AWSConnectionSuite ./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.AWSSignInSuite ./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.main.TrackingStartTrackingTest diff --git a/app/src/androidTest/java/com/aws/amazonlocation/BaseTestMainActivity.kt b/app/src/androidTest/java/com/aws/amazonlocation/BaseTestMainActivity.kt index 4a793cc0..8939100b 100644 --- a/app/src/androidTest/java/com/aws/amazonlocation/BaseTestMainActivity.kt +++ b/app/src/androidTest/java/com/aws/amazonlocation/BaseTestMainActivity.kt @@ -19,27 +19,9 @@ abstract class BaseTestMainActivity { private val defaultPermissions = arrayOf( ACCESS_FINE_LOCATION, - ACCESS_COARSE_LOCATION, - WRITE_EXTERNAL_STORAGE, + ACCESS_COARSE_LOCATION ) - private val permission: Array - get() { - return enablePermissions().let { - if (it.isEmpty()) { - arrayOf(WRITE_EXTERNAL_STORAGE) - } else { - it.contains(WRITE_EXTERNAL_STORAGE).let { hasWritePermission -> - if (hasWritePermission) { - it - } else { - it + WRITE_EXTERNAL_STORAGE - } - } - } - } - } - private val instance: BaseTestMainActivity get() { return getClassInstance() @@ -50,11 +32,6 @@ abstract class BaseTestMainActivity { @get:Rule(order = 0) var hiltRule = HiltAndroidRule(instance) - @get:Rule(order = 1) - var permissionRule: GrantPermissionRule = GrantPermissionRule.grant( - *permission, - ) - @JvmField @Rule(order = 2) val ruleChain: RuleChain = RuleChain diff --git a/app/src/androidTest/java/com/aws/amazonlocation/ui/DefaultConnectionFlowSuite2.kt b/app/src/androidTest/java/com/aws/amazonlocation/ui/DefaultConnectionFlowSuite2.kt index 12bf4376..31bc2b02 100644 --- a/app/src/androidTest/java/com/aws/amazonlocation/ui/DefaultConnectionFlowSuite2.kt +++ b/app/src/androidTest/java/com/aws/amazonlocation/ui/DefaultConnectionFlowSuite2.kt @@ -1,13 +1,11 @@ package com.aws.amazonlocation.ui import com.aws.amazonlocation.ui.main.CheckGoButtonClickLiveNavigationTest -import com.aws.amazonlocation.ui.main.CheckGrabGoButtonTest import com.aws.amazonlocation.ui.main.CheckRouteEstimatedTimeAndDistanceTest import com.aws.amazonlocation.ui.main.CheckRouteMapAdjustedTest import com.aws.amazonlocation.ui.main.CheckRouteOptionsTest import com.aws.amazonlocation.ui.main.CheckRouteUserEnterMyLocationTest import com.aws.amazonlocation.ui.main.ExploreFragmentChangeStyleTest -import com.aws.amazonlocation.ui.main.ExploreFragmentGrabChangeStyleTest import com.aws.amazonlocation.ui.main.ExploreFragmentMapStyleSearchFilterTest import com.aws.amazonlocation.ui.main.ExploreFragmentSearchResultTest import com.aws.amazonlocation.ui.main.ExploreFragmentSearchTotalResultTest @@ -19,13 +17,9 @@ import com.aws.amazonlocation.ui.main.SearchPlaceDisplayedOnMapTest import com.aws.amazonlocation.ui.main.SearchResultComparisonTest import com.aws.amazonlocation.ui.main.SettingRouteOptionAvailableTest import com.aws.amazonlocation.ui.main.SettingsFragmentChangeDataProviderTest -import com.aws.amazonlocation.ui.main.SettingsFragmentChangeLanguageTest -import com.aws.amazonlocation.ui.main.SettingsFragmentChangeRegionTest import com.aws.amazonlocation.ui.main.SettingsFragmentContentTest import com.aws.amazonlocation.ui.main.SettingsFragmentDefaultRouteTest import com.aws.amazonlocation.ui.main.SettingsMapStyleSearchFilterTest -import com.aws.amazonlocation.ui.main.SimulationStartTrackingHistoryLoggedTest -import com.aws.amazonlocation.ui.main.SimulationStopTrackingHistoryLoggedTest import org.junit.runner.RunWith import org.junit.runners.Suite @@ -50,12 +44,6 @@ import org.junit.runners.Suite SettingsFragmentDefaultRouteTest::class, ExploreFragmentChangeStyleTest::class, ExploreFragmentMapStyleSearchFilterTest::class, - SettingsMapStyleSearchFilterTest::class, - SimulationStartTrackingHistoryLoggedTest::class, - SimulationStopTrackingHistoryLoggedTest::class, - SettingsFragmentChangeRegionTest::class, - SettingsFragmentChangeLanguageTest::class, - ExploreFragmentGrabChangeStyleTest::class, - CheckGrabGoButtonTest::class + SettingsMapStyleSearchFilterTest::class ) class DefaultConnectionFlowSuite2 diff --git a/app/src/androidTest/java/com/aws/amazonlocation/ui/DefaultConnectionFlowSuite3.kt b/app/src/androidTest/java/com/aws/amazonlocation/ui/DefaultConnectionFlowSuite3.kt new file mode 100644 index 00000000..2d7cda24 --- /dev/null +++ b/app/src/androidTest/java/com/aws/amazonlocation/ui/DefaultConnectionFlowSuite3.kt @@ -0,0 +1,17 @@ +package com.aws.amazonlocation.ui + +import com.aws.amazonlocation.ui.main.CheckGrabGoButtonTest +import com.aws.amazonlocation.ui.main.ExploreFragmentGrabChangeStyleTest +import com.aws.amazonlocation.ui.main.SettingsFragmentChangeLanguageTest +import com.aws.amazonlocation.ui.main.SettingsFragmentChangeRegionTest +import org.junit.runner.RunWith +import org.junit.runners.Suite + +@RunWith(Suite::class) +@Suite.SuiteClasses( + SettingsFragmentChangeRegionTest::class, + SettingsFragmentChangeLanguageTest::class, + ExploreFragmentGrabChangeStyleTest::class, + CheckGrabGoButtonTest::class +) +class DefaultConnectionFlowSuite3 diff --git a/app/src/androidTest/java/com/aws/amazonlocation/ui/main/SettingsFragmentDefaultRouteTest.kt b/app/src/androidTest/java/com/aws/amazonlocation/ui/main/SettingsFragmentDefaultRouteTest.kt index e29036b9..11d1c2f2 100644 --- a/app/src/androidTest/java/com/aws/amazonlocation/ui/main/SettingsFragmentDefaultRouteTest.kt +++ b/app/src/androidTest/java/com/aws/amazonlocation/ui/main/SettingsFragmentDefaultRouteTest.kt @@ -5,8 +5,8 @@ import androidx.appcompat.widget.SwitchCompat import androidx.recyclerview.widget.RecyclerView import androidx.test.core.app.ApplicationProvider import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions import androidx.test.espresso.action.ViewActions.click -import androidx.test.espresso.action.ViewActions.replaceText import androidx.test.espresso.assertion.ViewAssertions import androidx.test.espresso.contrib.RecyclerViewActions import androidx.test.espresso.matcher.ViewMatchers.* // ktlint-disable no-wildcard-imports @@ -103,23 +103,13 @@ class SettingsFragmentDefaultRouteTest : BaseTestMainActivity() { Thread.sleep(DELAY_2000) val sourceEdt = waitForView(CoreMatchers.allOf(withId(R.id.edt_search_direction), isDisplayed())) - sourceEdt?.perform(replaceText(SEARCH_TEST_WORD_1)) + sourceEdt?.perform(click()) Thread.sleep(DELAY_2000) - val suggestionListSrcRv = waitForView( - CoreMatchers.allOf( - withId(R.id.rv_search_places_suggestion_direction), - isDisplayed(), - hasMinimumChildCount(1), - ), - ) - suggestionListSrcRv?.perform( - RecyclerViewActions.actionOnItemAtPosition( - 0, - click(), - ), - ) + val clMyLocation = + waitForView(CoreMatchers.allOf(withText(R.string.label_my_location), isDisplayed())) + clMyLocation?.perform(click()) Thread.sleep(DELAY_2000) @@ -129,18 +119,18 @@ class SettingsFragmentDefaultRouteTest : BaseTestMainActivity() { isDisplayed(), ), ) - destinationEdt?.perform(replaceText(SEARCH_TEST_WORD_2)) + destinationEdt?.perform(click(), ViewActions.replaceText(TEST_WORD_4)) Thread.sleep(DELAY_2000) - val suggestionListDestRv = waitForView( + val suggestionListRv = waitForView( CoreMatchers.allOf( withId(R.id.rv_search_places_suggestion_direction), isDisplayed(), hasMinimumChildCount(1), ), ) - suggestionListDestRv?.perform( + suggestionListRv?.perform( RecyclerViewActions.actionOnItemAtPosition( 0, click(), diff --git a/app/src/main/java/com/aws/amazonlocation/ui/main/explore/MapStyleInnerAdapter.kt b/app/src/main/java/com/aws/amazonlocation/ui/main/explore/MapStyleInnerAdapter.kt index 9e665a1d..325c7408 100644 --- a/app/src/main/java/com/aws/amazonlocation/ui/main/explore/MapStyleInnerAdapter.kt +++ b/app/src/main/java/com/aws/amazonlocation/ui/main/explore/MapStyleInnerAdapter.kt @@ -8,8 +8,10 @@ import com.aws.amazonlocation.R import com.aws.amazonlocation.data.response.MapStyleInnerData import com.aws.amazonlocation.databinding.ItemMapNameBinding import com.aws.amazonlocation.utils.DESCRIPTION_TAG_ESRI +import com.aws.amazonlocation.utils.DESCRIPTION_TAG_GRAB import com.aws.amazonlocation.utils.DESCRIPTION_TAG_HERE import com.aws.amazonlocation.utils.DESCRIPTION_TAG_OPEN +import com.aws.amazonlocation.utils.GRAB import com.aws.amazonlocation.utils.HERE import com.aws.amazonlocation.utils.OPEN @@ -61,6 +63,8 @@ class MapStyleInnerAdapter( DESCRIPTION_TAG_HERE + position } else if (innerStyle.mMapStyleName?.contains(OPEN) == true) { DESCRIPTION_TAG_OPEN + position + } else if (innerStyle.mMapStyleName?.contains(GRAB) == true) { + DESCRIPTION_TAG_GRAB + position } else { DESCRIPTION_TAG_ESRI + position } diff --git a/app/src/main/java/com/aws/amazonlocation/utils/Constants.kt b/app/src/main/java/com/aws/amazonlocation/utils/Constants.kt index d37a685f..3e405cc8 100644 --- a/app/src/main/java/com/aws/amazonlocation/utils/Constants.kt +++ b/app/src/main/java/com/aws/amazonlocation/utils/Constants.kt @@ -90,9 +90,11 @@ const val TYPE_RASTER = "Raster" const val HERE = "Here" const val OPEN = "Open" +const val GRAB = "Grab" const val DESCRIPTION_TAG_ESRI = "ESRI_" const val DESCRIPTION_TAG_HERE = "HERE_" const val DESCRIPTION_TAG_OPEN = "OPEN_" +const val DESCRIPTION_TAG_GRAB = "GRAB_" const val MAP_STYLE_ATTRIBUTION = "MapStyleAttribution" diff --git a/app/src/main/java/com/aws/amazonlocation/utils/DialogUtils.kt b/app/src/main/java/com/aws/amazonlocation/utils/DialogUtils.kt index c5dc28f2..bc9d7c93 100644 --- a/app/src/main/java/com/aws/amazonlocation/utils/DialogUtils.kt +++ b/app/src/main/java/com/aws/amazonlocation/utils/DialogUtils.kt @@ -183,7 +183,7 @@ fun Context.restartAppMapStyleDialog( val mDialog = MaterialAlertDialogBuilder(this, R.style.MyGrabDialogTheme) - mDialog.setTitle(resources.getString(R.string.label_restart_app_title)) + mDialog.setTitle(if (isRunningTest) resources.getString(R.string.grab) else resources.getString(R.string.label_restart_app_title)) mDialog.setMessage(R.string.label_restart_app_description) mDialog.setView(customView) mDialog.setPositiveButton(