Skip to content

Commit

Permalink
Merge pull request #83 from makeen-project/fix/e2e_test_case
Browse files Browse the repository at this point in the history
E2E test case fixes
  • Loading branch information
shah279 authored Oct 4, 2023
2 parents 904ee83 + e82a81b commit 12d27c6
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 57 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test-android-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Run E2E Tests for Android
on:
workflow_dispatch:
pull_request:
branches: [ main ]
jobs:
test-android:
name: Test Android
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>
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()
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<RecyclerView.ViewHolder>(
0,
click(),
),
)
val clMyLocation =
waitForView(CoreMatchers.allOf(withText(R.string.label_my_location), isDisplayed()))
clMyLocation?.perform(click())

Thread.sleep(DELAY_2000)

Expand All @@ -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<RecyclerView.ViewHolder>(
0,
click(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/aws/amazonlocation/utils/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 12d27c6

Please sign in to comment.