-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from aws-geospatial/ALS-1927_optimize_E2E_tes…
…t_cases ALS-1927 Optimize all E2E test case
- Loading branch information
Showing
62 changed files
with
2,261 additions
and
3,200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 35 additions & 67 deletions
102
.../androidTest/java/com/aws/amazonlocation/ui/main/AfterSearchDirectionButtonWorkingTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,74 @@ | ||
package com.aws.amazonlocation.ui.main | ||
|
||
import android.view.View | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import androidx.recyclerview.widget.RecyclerView | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.Espresso.pressBack | ||
import androidx.test.espresso.action.ViewActions.click | ||
import androidx.test.espresso.action.ViewActions.replaceText | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.hasMinimumChildCount | ||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed | ||
import androidx.test.espresso.matcher.ViewMatchers.withId | ||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation | ||
import androidx.test.uiautomator.By | ||
import androidx.test.uiautomator.UiDevice | ||
import androidx.test.uiautomator.Until | ||
import com.aws.amazonlocation.AMAZON_MAP_READY | ||
import com.aws.amazonlocation.BaseTestMainActivity | ||
import com.aws.amazonlocation.BuildConfig | ||
import com.aws.amazonlocation.DELAY_15000 | ||
import com.aws.amazonlocation.DELAY_2000 | ||
import com.aws.amazonlocation.DELAY_20000 | ||
import com.aws.amazonlocation.DELAY_5000 | ||
import com.aws.amazonlocation.R | ||
import com.aws.amazonlocation.TEST_FAILED_DIRECTION_CARD | ||
import com.aws.amazonlocation.TEST_FAILED | ||
import com.aws.amazonlocation.TEST_FAILED_NO_SEARCH_RESULT | ||
import com.aws.amazonlocation.TEST_FAILED_SEARCH_FIELD_NOT_VISIBLE | ||
import com.aws.amazonlocation.TEST_FAILED_SEARCH_SHEET | ||
import com.aws.amazonlocation.TEST_WORD_RIO_TINTO | ||
import com.aws.amazonlocation.checkLocationPermission | ||
import com.aws.amazonlocation.di.AppModule | ||
import com.aws.amazonlocation.enableGPS | ||
import com.aws.amazonlocation.failTest | ||
import com.google.android.material.bottomsheet.BottomSheetBehavior | ||
import com.google.android.material.card.MaterialCardView | ||
import com.google.android.material.textfield.TextInputEditText | ||
import com.aws.amazonlocation.waitForView | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import dagger.hilt.android.testing.UninstallModules | ||
import org.hamcrest.CoreMatchers.allOf | ||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
@UninstallModules(AppModule::class) | ||
@HiltAndroidTest | ||
class AfterSearchDirectionButtonWorkingTest : BaseTestMainActivity() { | ||
|
||
private val uiDevice = UiDevice.getInstance(getInstrumentation()) | ||
|
||
@Test | ||
fun showAfterSearchDirectionButtonWorkingTest() { | ||
try { | ||
enableGPS(ApplicationProvider.getApplicationContext()) | ||
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000) | ||
Thread.sleep(DELAY_2000) | ||
|
||
checkLocationPermission() | ||
val edtSearch = | ||
onView(withId(R.id.edt_search_places)).check(matches(isDisplayed())) | ||
edtSearch.perform(click()) | ||
onView(withId(R.id.edt_search_places)).perform(replaceText(TEST_WORD_RIO_TINTO)) | ||
|
||
uiDevice.wait( | ||
Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/rv_search_places_suggestion")), | ||
DELAY_20000, | ||
) | ||
Thread.sleep(DELAY_2000) | ||
val rvSearchPlaceSuggestion = | ||
mActivityRule.activity.findViewById<RecyclerView>(R.id.rv_search_places_suggestion) | ||
if (rvSearchPlaceSuggestion.adapter?.itemCount != null) { | ||
rvSearchPlaceSuggestion.adapter?.itemCount?.let { | ||
if (it >= 0) { | ||
val clSearchSheet = | ||
mActivityRule.activity.findViewById<ConstraintLayout>(R.id.bottom_sheet_search) | ||
if (clSearchSheet.visibility == View.VISIBLE) { | ||
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) | ||
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) | ||
Assert.assertTrue(TEST_FAILED_SEARCH_FIELD_NOT_VISIBLE, edtSearchDirection.visibility == View.VISIBLE) | ||
} else { | ||
Assert.fail(TEST_FAILED_DIRECTION_CARD) | ||
} | ||
} else { | ||
Assert.fail(TEST_FAILED_SEARCH_SHEET) | ||
} | ||
} else { | ||
Assert.fail(TEST_FAILED_NO_SEARCH_RESULT) | ||
} | ||
waitForView( | ||
allOf( | ||
withId(R.id.rv_search_places_suggestion), | ||
isDisplayed(), | ||
hasMinimumChildCount(1), | ||
), | ||
) | ||
|
||
var itemCount = 0 | ||
rvSearchPlaceSuggestion?.check { view, _ -> | ||
if (view is RecyclerView) { | ||
itemCount = view.adapter?.itemCount ?: 0 | ||
} else { | ||
Assert.fail(TEST_FAILED_NO_SEARCH_RESULT) | ||
} | ||
} | ||
if (itemCount >= 0) { | ||
pressBack() | ||
|
||
val cardDirectionTest = | ||
onView(withId(R.id.card_direction)).check(matches(isDisplayed())) | ||
cardDirectionTest.perform(click()) | ||
waitForView( | ||
allOf( | ||
withId(R.id.edt_search_direction), | ||
isDisplayed(), | ||
), | ||
) | ||
} else { | ||
Assert.fail(TEST_FAILED_NO_SEARCH_RESULT) | ||
} | ||
} catch (e: Exception) { | ||
failTest(118, e) | ||
Assert.fail("$TEST_FAILED ${e.message}") | ||
} | ||
} | ||
} |
Oops, something went wrong.