Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E test case fixes #83

Merged
merged 3 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test-android-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ jobs:
adb emu geo fix 72.58727 23.02579
./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
Loading