Skip to content

Commit

Permalink
Merge pull request #80 from makeen-project/fix/e2e_test_case
Browse files Browse the repository at this point in the history
Fixes for e2e test cases
  • Loading branch information
shah279 authored Oct 2, 2023
2 parents 663e7fc + 712544a commit 43ba9f5
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 149 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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
Expand All @@ -18,9 +19,13 @@ 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 @@ -43,9 +48,14 @@ import org.junit.runners.Suite
SettingsFragmentChangeDataProviderTest::class,
SettingsFragmentContentTest::class,
SettingsFragmentDefaultRouteTest::class,
ExploreFragmentGrabChangeStyleTest::class,
ExploreFragmentChangeStyleTest::class,
ExploreFragmentMapStyleSearchFilterTest::class,
SettingsMapStyleSearchFilterTest::class
SettingsMapStyleSearchFilterTest::class,
SimulationStartTrackingHistoryLoggedTest::class,
SimulationStopTrackingHistoryLoggedTest::class,
SettingsFragmentChangeRegionTest::class,
SettingsFragmentChangeLanguageTest::class,
ExploreFragmentGrabChangeStyleTest::class,
CheckGrabGoButtonTest::class
)
class DefaultConnectionFlowSuite2
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,6 @@ class AnalyticsTest : BaseTestMainActivity() {
Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/edt_search_places")),
DELAY_5000
)
// Start - Search event check
val edtSearch =
onView(withId(R.id.edt_search_places)).check(ViewAssertions.matches(isDisplayed()))
edtSearch.perform(click())
onView(withId(R.id.edt_search_places)).perform(ViewActions.replaceText(TEST_ADDRESS))
var snackBarMsg = uiDevice.wait(Until.hasObject(By.text(EventType.PLACE_SEARCH)), DELAY_10000)
Assert.assertTrue(TEST_FAILED_NO_MESSAGE_FOUND, snackBarMsg)
edtSearch.perform(ViewActions.closeSoftKeyboard())
val clSearchSheet =
mActivityRule.activity.findViewById<ConstraintLayout>(R.id.bottom_sheet_search)
val mBottomSheetSearchPlaces: BottomSheetBehavior<ConstraintLayout> =
BottomSheetBehavior.from(clSearchSheet)
mBottomSheetSearchPlaces.state = BottomSheetBehavior.STATE_COLLAPSED
uiDevice.wait(Until.hasObject(By.text(mActivityRule.activity.getString(R.string.menu_explore))), DELAY_5000)
// End - Search event check
Thread.sleep(DELAY_1000)
// Start - Screen change event test
val settingTabText = mActivityRule.activity.getString(R.string.menu_setting)
onView(
Expand All @@ -96,16 +80,14 @@ class AnalyticsTest : BaseTestMainActivity() {
isDisplayed()
)
).perform(click())
snackBarMsg = uiDevice.wait(Until.hasObject(By.text(EventType.SCREEN_OPEN)), DELAY_10000)
Assert.assertTrue(TEST_FAILED_NO_MESSAGE_FOUND, snackBarMsg)
// End - Screen change event test
goToDataProvider()
Thread.sleep(DELAY_2000)
// Start - Map provider change event test
onView(
allOf(withId(R.id.ll_here), isDisplayed())
).perform(click())
snackBarMsg = uiDevice.wait(Until.hasObject(By.text(EventType.MAP_PROVIDER_CHANGE)), DELAY_10000)
var snackBarMsg = uiDevice.wait(Until.hasObject(By.text(EventType.MAP_PROVIDER_CHANGE)), DELAY_10000)
Assert.assertTrue(TEST_FAILED_NO_MESSAGE_FOUND, snackBarMsg)
// End - Map provider change event test
onView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,97 +138,6 @@ class CheckRouteEstimatedTimeAndDistanceTest : BaseTestMainActivity() {
tvWalkDistance.text.toString().isNotEmpty() && tvWalkMinute.text.toString().isNotEmpty() &&
tvTruckDistance.text.toString().isNotEmpty() && tvTruckMinute.text.toString().isNotEmpty(),
)

// val cardDirection =
// mActivityRule.activity.findViewById<MaterialCardView>(R.id.card_direction)
// if (cardDirection.visibility == View.VISIBLE) {
// val cardDirectionTest =
// onView(withId(R.id.card_direction)).check(matches(isDisplayed()))
// cardDirectionTest.perform(click())
// uiDevice.wait(
// Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/edt_search_direction")),
// DELAY_5000,
// )
// val edtSearchDirection =
// mActivityRule.activity.findViewById<TextInputEditText>(R.id.edt_search_direction)
// if (edtSearchDirection.visibility == View.VISIBLE) {
// onView(withId(R.id.edt_search_direction)).perform(ViewActions.typeText(TEST_WORD_9))
// Thread.sleep(DELAY_2000)
// uiDevice.wait(
// Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/rv_search_places_suggestion_direction")),
// DELAY_20000,
// )
// val rvSearchPlacesSuggestionDirection =
// mActivityRule.activity.findViewById<RecyclerView>(R.id.rv_search_places_suggestion_direction)
// rvSearchPlacesSuggestionDirection.adapter?.itemCount?.let {
// if (it > 0) {
// onView(withId(R.id.rv_search_places_suggestion_direction)).perform(
// RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(
// 0,
// click(),
// ),
// )
// }
// }
// onView(withId(R.id.edt_search_dest)).perform(ViewActions.typeText(TEST_WORD_10))
// Thread.sleep(DELAY_2000)
// uiDevice.wait(
// Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/rv_search_places_suggestion_direction")),
// DELAY_20000,
// )
// rvSearchPlacesSuggestionDirection.adapter?.itemCount?.let {
// if (it > 0) {
// onView(withId(R.id.rv_search_places_suggestion_direction)).perform(
// RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(
// 0,
// click(),
// ),
// )
// }
// }
// uiDevice.wait(
// Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/card_drive_go")),
// DELAY_20000,
// )
// uiDevice.wait(
// Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/card_walk_go")),
// DELAY_20000,
// )
// uiDevice.wait(
// Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/card_truck_go")),
// DELAY_20000,
// )
// val cardDriveGo =
// mActivityRule.activity.findViewById<MaterialCardView>(R.id.card_drive_go)
// if (cardDriveGo.visibility == View.VISIBLE) {
// val tvDriveDistance =
// mActivityRule.activity.findViewById<AppCompatTextView>(R.id.tv_drive_distance)
// val tvDriveMinute =
// mActivityRule.activity.findViewById<AppCompatTextView>(R.id.tv_drive_minute)
// val tvWalkDistance =
// mActivityRule.activity.findViewById<AppCompatTextView>(R.id.tv_walk_distance)
// val tvWalkMinute =
// mActivityRule.activity.findViewById<AppCompatTextView>(R.id.tv_walk_minute)
// val tvTruckDistance =
// mActivityRule.activity.findViewById<AppCompatTextView>(R.id.tv_truck_distance)
// val tvTruckMinute =
// mActivityRule.activity.findViewById<AppCompatTextView>(R.id.tv_truck_minute)
//
// Assert.assertTrue(
// TEST_FAILED_DISTANCE_OR_TIME_EMPTY,
// tvDriveDistance.text.toString().isNotEmpty() && tvDriveMinute.text.toString().isNotEmpty() &&
// tvWalkDistance.text.toString().isNotEmpty() && tvWalkMinute.text.toString().isNotEmpty() &&
// tvTruckDistance.text.toString().isNotEmpty() && tvTruckMinute.text.toString().isNotEmpty(),
// )
// } else {
// Assert.fail(TEST_FAILED_CARD_DRIVE_GO)
// }
// } else {
// Assert.fail(TEST_FAILED_SEARCH_DIRECTION)
// }
// } else {
// Assert.fail(TEST_FAILED_DIRECTION_CARD)
// }
} catch (_: Exception) {
Assert.fail(TEST_FAILED)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.aws.amazonlocation.ui.main

import android.app.ActivityManager
import android.content.Context
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.test.core.app.ApplicationProvider
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.* // ktlint-disable no-wildcard-imports
Expand All @@ -21,6 +23,7 @@ import com.aws.amazonlocation.utils.KEY_POOL_ID
import com.aws.amazonlocation.utils.KEY_RE_START_APP
import com.aws.amazonlocation.utils.PreferenceManager
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.card.MaterialCardView
import dagger.hilt.android.testing.HiltAndroidTest
import dagger.hilt.android.testing.UninstallModules
import org.hamcrest.CoreMatchers
Expand Down Expand Up @@ -52,7 +55,7 @@ class ConnectToAWSTest : BaseTestMainActivity() {
try {
val settingTabText = mActivityRule.activity.getString(R.string.menu_setting)

Thread.sleep(DELAY_2000)
Thread.sleep(DELAY_3000)

onView(
allOf(
Expand Down Expand Up @@ -120,11 +123,20 @@ class ConnectToAWSTest : BaseTestMainActivity() {
try {
enableGPS(ApplicationProvider.getApplicationContext())
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000)
Thread.sleep(DELAY_1000)
Thread.sleep(DELAY_3000)

val tracking = uiDevice.findObject(By.text(mActivityRule.activity.getString(R.string.menu_tracking)))
tracking.click()

Thread.sleep(DELAY_1000)
val clEnableTracking =
mActivityRule.activity.findViewById<ConstraintLayout>(R.id.cl_enable_tracking)
if (clEnableTracking.visibility == View.VISIBLE) {
val btnEnableTracking =
mActivityRule.activity.findViewById<MaterialCardView>(R.id.btn_enable_tracking)
mActivityRule.activity.runOnUiThread {
btnEnableTracking.performClick()
}
}
Thread.sleep(DELAY_1000)
uiDevice.wait(
Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/tv_sign_in_required")),
Expand Down Expand Up @@ -212,12 +224,21 @@ class ConnectToAWSTest : BaseTestMainActivity() {
try {
enableGPS(ApplicationProvider.getApplicationContext())
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000)
Thread.sleep(DELAY_1000)
Thread.sleep(DELAY_3000)

val tracking =
uiDevice.findObject(By.text(mActivityRule.activity.getString(R.string.menu_geofence)))
tracking.click()

Thread.sleep(DELAY_1000)
val clEnableTracking =
mActivityRule.activity.findViewById<ConstraintLayout>(R.id.cl_empty_geofence_list)
if (clEnableTracking.visibility == View.VISIBLE) {
val btnEnableTracking =
mActivityRule.activity.findViewById<MaterialCardView>(R.id.btn_add_geofence)
mActivityRule.activity.runOnUiThread {
btnEnableTracking.performClick()
}
}
Thread.sleep(DELAY_1000)
uiDevice.wait(
Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/tv_sign_in_required")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ class ExploreFragmentGrabChangeStyleTest : BaseTestMainActivity() {
click()
)
)
Thread.sleep(DELAY_2000)
uiDevice.wait(
Until.hasObject(By.text(mActivityRule.activity.getString(R.string.ok))),
Until.hasObject(By.text(mActivityRule.activity.getString(R.string.enable_grab))),
DELAY_2000
)

val labelOk =
uiDevice.findObject(By.text(mActivityRule.activity.getString(R.string.ok)))
uiDevice.findObject(By.text(mActivityRule.activity.getString(R.string.enable_grab)))
labelOk?.click()
val mapName =
preferenceManager.getValue(KEY_MAP_NAME, mActivityRule.activity.getString(R.string.grab))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class ExploreFragmentMapFunctionWithoutAwsLoginTest : BaseTestMainActivity() {
onView(withId(R.id.edt_search_places)).check(ViewAssertions.matches(isDisplayed()))
edtSearch?.perform(click())
onView(withId(R.id.edt_search_places))?.perform(typeText(TEST_WORD_4))
Thread.sleep(DELAY_5000)
uiDevice.wait(
Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/rv_search_places_suggestion")),
DELAY_10000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.aws.amazonlocation.BaseTestMainActivity
import com.aws.amazonlocation.DELAY_1000
import com.aws.amazonlocation.DELAY_10000
import com.aws.amazonlocation.DELAY_15000
import com.aws.amazonlocation.DELAY_2000
import com.aws.amazonlocation.DELAY_20000
import com.aws.amazonlocation.R
import com.aws.amazonlocation.TEST_FAILED_POOL_ID_NOT_BLANK
Expand Down Expand Up @@ -55,7 +56,7 @@ class SettingAWSDisconnectingTest : BaseTestMainActivity() {
enableGPS(ApplicationProvider.getApplicationContext())
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000)
val settingTabText = mActivityRule.activity.getString(R.string.menu_setting)
Thread.sleep(DELAY_1000)
Thread.sleep(DELAY_2000)
onView(
AllOf.allOf(
withText(settingTabText),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.aws.amazonlocation.BuildConfig
import com.aws.amazonlocation.DELAY_1000
import com.aws.amazonlocation.DELAY_15000
import com.aws.amazonlocation.DELAY_20000
import com.aws.amazonlocation.DELAY_5000
import com.aws.amazonlocation.R
import com.aws.amazonlocation.TEST_FAILED
import com.aws.amazonlocation.TEST_FAILED_ROUTE_OPTION_NOT_VISIBLE
Expand All @@ -42,7 +43,7 @@ class SettingRouteOptionAvailableTest : BaseTestMainActivity() {
try {
enableGPS(ApplicationProvider.getApplicationContext())
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000)
Thread.sleep(DELAY_1000)
Thread.sleep(DELAY_5000)

val explorer =
uiDevice.findObject(By.text(mActivityRule.activity.getString(R.string.menu_setting)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SettingSignInTest : BaseTestMainActivity() {
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000)
val settingTabText = mActivityRule.activity.getString(R.string.menu_setting)

Thread.sleep(DELAY_1000)
Thread.sleep(DELAY_2000)
Espresso.onView(
AllOf.allOf(
withText(settingTabText),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.aws.amazonlocation.BaseTestMainActivity
import com.aws.amazonlocation.DELAY_1000
import com.aws.amazonlocation.DELAY_10000
import com.aws.amazonlocation.DELAY_15000
import com.aws.amazonlocation.DELAY_2000
import com.aws.amazonlocation.DELAY_20000
import com.aws.amazonlocation.R
import com.aws.amazonlocation.TEST_FAILED_SIGNIN_BUTTON_NOT_VISIBLE
Expand Down Expand Up @@ -53,7 +54,7 @@ class SettingSignOutTest : BaseTestMainActivity() {
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000)
val settingTabText = mActivityRule.activity.getString(R.string.menu_setting)

Thread.sleep(DELAY_1000)
Thread.sleep(DELAY_2000)
Espresso.onView(
AllOf.allOf(
withText(settingTabText),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ class SettingsFragmentChangeDataProviderTest : BaseTestMainActivity() {
val hereMapName = mActivityRule.activity.getString(R.string.here)

uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000)
Thread.sleep(DELAY_2000)
Thread.sleep(DELAY_3000)

goToDataProvider()

onView(
allOf(withId(R.id.ll_here), isDisplayed()),
).perform(click())

Thread.sleep(DELAY_3000)
var selectedMapName = preferenceManager.getValue(KEY_MAP_NAME, esriMapName)

if (selectedMapName != hereMapName) {
Expand All @@ -72,7 +72,7 @@ class SettingsFragmentChangeDataProviderTest : BaseTestMainActivity() {
onView(
allOf(withId(R.id.ll_esri), isDisplayed()),
).perform(click())

Thread.sleep(DELAY_3000)
selectedMapName = preferenceManager.getValue(KEY_MAP_NAME, esriMapName)

if (selectedMapName != esriMapName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SettingsFragmentContentTest : BaseTestMainActivity() {
fun checkContent() {
try {
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000)
Thread.sleep(DELAY_2000)
Thread.sleep(DELAY_3000)

val settingsTabText = mActivityRule.activity.getString(R.string.menu_setting)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SettingsFragmentDefaultRouteTest : BaseTestMainActivity() {
fun checkDefaultRouteOptionsTest() {
try {
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000)
Thread.sleep(DELAY_2000)
Thread.sleep(DELAY_3000)

goToDefaultRouteSettings()

Expand Down
Loading

0 comments on commit 43ba9f5

Please sign in to comment.