Skip to content

Commit

Permalink
Merge pull request #98 from aws-geospatial/ALS-1889_map_language_and_…
Browse files Browse the repository at this point in the history
…political_view_update

ALS-1889 Map language support added and political view updated
  • Loading branch information
wadhawh authored Jan 10, 2025
2 parents a0abe8b + 7e3a717 commit 1bc50ff
Show file tree
Hide file tree
Showing 68 changed files with 2,317 additions and 1,556 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const val TEST_WORD_GUOCO_MIDTOWN_SQUARE = "Guoco Midtown Square"
const val TEST_WORD_KLUANG = "Kluang "
const val TEST_WORD_ARG = "ARG"
const val TEST_WORD_RUS = "RUS"
const val TEST_WORD_LANGUAGE_AR = "العربية"
const val TEST_WORD_LANGUAGE_BO = "Bosanski"
const val ACCESS_FINE_LOCATION = "android.permission.ACCESS_FINE_LOCATION"
const val ACCESS_COARSE_LOCATION = "android.permission.ACCESS_COARSE_LOCATION"
const val TEST_FAILED = "Test failed"
Expand All @@ -54,6 +56,7 @@ const val TEST_FAILED_SEARCH_DIRECTION = "Test failed due to search direction no
const val TEST_FAILED_ZOOM_LEVEL = "Test failed due to zoom level not available"
const val TEST_FAILED_LIST = "Test failed due to list not visible"
const val TEST_FAILED_COUNTRY= "Test failed due to selected country doesn't match"
const val TEST_FAILED_LANGUAGE= "Test failed due to selected language doesn't match"

const val TEST_FAILED_SETTINGS_ALL_OPTIONS_NOT_VISIBLE = "Test failed due to settings all options not visible"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package com.aws.amazonlocation.ui

import com.aws.amazonlocation.ui.main.CheckRouteMapAdjustedTest
import com.aws.amazonlocation.ui.main.ExploreFragmentChangeStyleTest
import com.aws.amazonlocation.ui.main.ExploreFragmentMapLanguageTest
import com.aws.amazonlocation.ui.main.ExploreFragmentPoliticalViewTest
import com.aws.amazonlocation.ui.main.ExploreFragmentSearchLocationByAddressTest
import com.aws.amazonlocation.ui.main.SearchResultComparisonTest
import com.aws.amazonlocation.ui.main.SettingRouteOptionAvailableTest
import com.aws.amazonlocation.ui.main.SettingsFragmentContentTest
import com.aws.amazonlocation.ui.main.SettingsFragmentDefaultRouteTest
import com.aws.amazonlocation.ui.main.SettingsMapLanguageTest
import com.aws.amazonlocation.ui.main.SettingsMapPoliticalViewTest
import org.junit.runner.RunWith
import org.junit.runners.Suite
Expand All @@ -23,5 +25,7 @@ import org.junit.runners.Suite
ExploreFragmentChangeStyleTest::class,
ExploreFragmentPoliticalViewTest::class,
SettingsMapPoliticalViewTest::class,
ExploreFragmentMapLanguageTest::class,
SettingsMapLanguageTest::class,
)
class MapStylesSettingAndExplorerFlowSuite
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ class ExploreFragmentPoliticalViewTest : BaseTestMainActivity() {

Thread.sleep(DELAY_2000)

val btnApplyFilter = uiDevice.findObject(UiSelector().resourceId("${BuildConfig.APPLICATION_ID}:id/btn_apply_filter"))
btnApplyFilter.click()

Thread.sleep(DELAY_2000)

val tvPoliticalDescription = uiDevice.findObject(UiSelector().resourceId("${BuildConfig.APPLICATION_ID}:id/tv_political_description"))
Assert.assertTrue(TEST_FAILED_COUNTRY, tvPoliticalDescription.text.contains(TEST_WORD_ARG))
} catch (e: Exception) {
Expand Down
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())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ class SettingsMapPoliticalViewTest : BaseTestMainActivity() {

Thread.sleep(DELAY_2000)

val btnApplyFilter = uiDevice.findObject(UiSelector().resourceId("${BuildConfig.APPLICATION_ID}:id/btn_apply_filter"))
btnApplyFilter.click()

Thread.sleep(DELAY_2000)

val tvPoliticalDescription = uiDevice.findObject(UiSelector().resourceId("${BuildConfig.APPLICATION_ID}:id/tv_political_description"))
Assert.assertTrue(TEST_FAILED_COUNTRY, tvPoliticalDescription.text.contains(TEST_WORD_RUS))
}
Expand Down
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
)
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,11 @@ class MainActivity :
}
moveToExploreScreen()
} else if (mBottomSheetHelper.isAttributeExpandedOrHalfExpand()) {
mBottomSheetHelper.hideAttributeSheet()
if (fragment is ExploreFragment) {
fragment.hideAttribution()
} else {
mBottomSheetHelper.hideAttributeSheet()
}
} else if (mBottomSheetHelper.isSearchBottomSheetExpandedOrHalfExpand()) {
mBottomSheetHelper.collapseSearchBottomSheet()
} else if (fragment is ExploreFragment && fragment.isMapStyleExpandedOrHalfExpand()) {
Expand Down
Loading

0 comments on commit 1bc50ff

Please sign in to comment.