-
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 #98 from aws-geospatial/ALS-1889_map_language_and_…
…political_view_update ALS-1889 Map language support added and political view updated
- Loading branch information
Showing
68 changed files
with
2,317 additions
and
1,556 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
96 changes: 96 additions & 0 deletions
96
app/src/androidTest/java/com/aws/amazonlocation/ui/main/ExploreFragmentMapLanguageTest.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 |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package com.aws.amazonlocation.ui.main | ||
|
||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.action.ViewActions.click | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.* | ||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation | ||
import androidx.test.uiautomator.By | ||
import androidx.test.uiautomator.UiDevice | ||
import androidx.test.uiautomator.UiSelector | ||
import androidx.test.uiautomator.Until | ||
import com.aws.amazonlocation.* | ||
import com.aws.amazonlocation.di.AppModule | ||
import com.aws.amazonlocation.utils.* | ||
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 ExploreFragmentMapLanguageTest : BaseTestMainActivity() { | ||
|
||
private val uiDevice = UiDevice.getInstance(getInstrumentation()) | ||
|
||
private lateinit var preferenceManager: PreferenceManager | ||
|
||
@Throws(java.lang.Exception::class) | ||
override fun before() { | ||
preferenceManager = PreferenceManager(ApplicationProvider.getApplicationContext()) | ||
preferenceManager.setValue(IS_APP_FIRST_TIME_OPENED, true) | ||
preferenceManager.removeValue(KEY_MAP_NAME) | ||
preferenceManager.removeValue(KEY_MAP_STYLE_NAME) | ||
super.before() | ||
} | ||
|
||
@Test | ||
fun testMapLanguageChangeTest() { | ||
try { | ||
val btnContinueToApp = uiDevice.findObject(UiSelector().resourceId("${BuildConfig.APPLICATION_ID}:id/btn_continue_to_app")) | ||
if (btnContinueToApp.exists()) { | ||
btnContinueToApp.click() | ||
Thread.sleep(DELAY_2000) | ||
} | ||
uiDevice.findObject(By.text(WHILE_USING_THE_APP))?.click() | ||
uiDevice.findObject(By.text(WHILE_USING_THE_APP_CAPS))?.click() | ||
uiDevice.findObject(By.text(WHILE_USING_THE_APP_ALLOW))?.click() | ||
uiDevice.findObject(By.text(ALLOW))?.click() | ||
enableGPS(ApplicationProvider.getApplicationContext()) | ||
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000) | ||
|
||
goToMapStyles() | ||
|
||
val clMapLanguage = | ||
onView(withId(R.id.cl_map_language)).check(matches(isDisplayed())) | ||
clMapLanguage.perform(click()) | ||
|
||
val language = | ||
waitForView(allOf(withText(TEST_WORD_LANGUAGE_AR), isDisplayed())) | ||
language?.perform(click()) | ||
|
||
val description = uiDevice.findObject(UiSelector().resourceId("${BuildConfig.APPLICATION_ID}:id/tv_map_language_description")) | ||
Assert.assertTrue(TEST_FAILED_LANGUAGE, description.text.contains(TEST_WORD_LANGUAGE_AR)) | ||
} catch (e: Exception) { | ||
failTest(147, e) | ||
Assert.fail(TEST_FAILED) | ||
} | ||
} | ||
|
||
private fun goToMapStyles() { | ||
val cardMap = waitForView(allOf(withId(R.id.card_map), isDisplayed())) | ||
cardMap?.perform(click()) | ||
|
||
waitForView(allOf(withId(R.id.cl_map_language), isDisplayed())) | ||
swipeUp() | ||
} | ||
|
||
private fun swipeUp(): UiDevice? { | ||
// Get the screen dimensions | ||
val screenHeight = getInstrumentation().targetContext.resources.displayMetrics.heightPixels | ||
|
||
// Set the starting point for the swipe (bottom-center of the screen) | ||
val startX = getInstrumentation().targetContext.resources.displayMetrics.widthPixels / 2f | ||
val startY = screenHeight - 100 // Offset from the bottom of the screen | ||
|
||
// Set the ending point for the swipe (top-center of the screen) | ||
val endY = 100 // Offset from the top of the screen | ||
|
||
// Perform the swipe action | ||
val uiDevice = UiDevice.getInstance(getInstrumentation()) | ||
uiDevice.swipe(startX.toInt(), startY, startX.toInt(), endY, 10) | ||
return uiDevice | ||
} | ||
} |
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
76 changes: 76 additions & 0 deletions
76
app/src/androidTest/java/com/aws/amazonlocation/ui/main/SettingsMapLanguageTest.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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.aws.amazonlocation.ui.main | ||
|
||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.action.ViewActions.click | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.* | ||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation | ||
import androidx.test.uiautomator.By | ||
import androidx.test.uiautomator.UiDevice | ||
import androidx.test.uiautomator.UiSelector | ||
import androidx.test.uiautomator.Until | ||
import com.aws.amazonlocation.* | ||
import com.aws.amazonlocation.di.AppModule | ||
import com.aws.amazonlocation.utils.* | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import dagger.hilt.android.testing.UninstallModules | ||
import org.hamcrest.CoreMatchers.allOf | ||
import org.hamcrest.core.AllOf | ||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
@UninstallModules(AppModule::class) | ||
@HiltAndroidTest | ||
class SettingsMapLanguageTest : BaseTestMainActivity() { | ||
|
||
private val uiDevice = UiDevice.getInstance(getInstrumentation()) | ||
|
||
private lateinit var preferenceManager: PreferenceManager | ||
|
||
@Throws(java.lang.Exception::class) | ||
override fun before() { | ||
preferenceManager = PreferenceManager(ApplicationProvider.getApplicationContext()) | ||
preferenceManager.setValue(IS_APP_FIRST_TIME_OPENED, true) | ||
super.before() | ||
} | ||
|
||
@Test | ||
fun testSettingsMapPoliticalViewTest() { | ||
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000) | ||
|
||
goToMapStyles() | ||
|
||
waitForView( | ||
AllOf.allOf( | ||
withId(R.id.cl_map_language), | ||
isDisplayed() | ||
) | ||
)?.perform(click()) | ||
|
||
val language = | ||
waitForView(allOf(withText(TEST_WORD_LANGUAGE_BO), isDisplayed())) | ||
language?.perform(click()) | ||
|
||
val description = uiDevice.findObject(UiSelector().resourceId("${BuildConfig.APPLICATION_ID}:id/tv_map_language_description")) | ||
Assert.assertTrue(TEST_FAILED_LANGUAGE, description.text.contains(TEST_WORD_LANGUAGE_BO)) | ||
} | ||
|
||
private fun goToMapStyles() { | ||
waitForView( | ||
AllOf.allOf( | ||
withText(mActivityRule.activity.getString(R.string.menu_setting)), | ||
isDescendantOfA(withId(R.id.bottom_navigation_main)), | ||
isDisplayed() | ||
) | ||
)?.perform(click()) | ||
|
||
|
||
waitForView( | ||
AllOf.allOf( | ||
withId(R.id.cl_map_style), | ||
isDisplayed() | ||
) | ||
)?.perform(click()) | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/aws/amazonlocation/data/response/LanguageData.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.aws.amazonlocation.data.response | ||
|
||
data class LanguageData( | ||
val value: String, | ||
val label: String, | ||
var isSelected: Boolean = false | ||
) |
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
Oops, something went wrong.