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

ALS-1889 zoom level fix, Chinese language name changes and removed unused strings #116

Merged
merged 5 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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,106 @@
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 {
Thread.sleep(DELAY_2000)
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()
Thread.sleep(DELAY_2000)
enableGPS(ApplicationProvider.getApplicationContext())
Thread.sleep(DELAY_2000)
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000)

Thread.sleep(DELAY_2000)

goToMapStyles()

val clMapLanguage =
onView(withId(R.id.cl_map_language)).check(matches(isDisplayed()))
clMapLanguage.perform(click())

Thread.sleep(DELAY_2000)

val language =
waitForView(allOf(withText(TEST_WORD_LANGUAGE_AR), isDisplayed()))
language?.perform(click())

Thread.sleep(DELAY_2000)

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())

Thread.sleep(DELAY_2000)
swipeUp()
Thread.sleep(DELAY_2000)
}

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
@@ -0,0 +1,85 @@
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() {
Thread.sleep(DELAY_2000)

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

goToMapStyles()

val clPoliticalView =
onView(withId(R.id.cl_map_language)).check(matches(isDisplayed()))
clPoliticalView.perform(click())

Thread.sleep(DELAY_2000)

val language =
waitForView(allOf(withText(TEST_WORD_LANGUAGE_BO), isDisplayed()))
language?.perform(click())

Thread.sleep(DELAY_2000)

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())

Thread.sleep(DELAY_3000)

waitForView(
AllOf.allOf(
withId(R.id.cl_map_style),
isDisplayed()
)
)
?.perform(click())

Thread.sleep(DELAY_3000)
}
}
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
)
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import com.aws.amazonlocation.utils.KEY_CLOUD_FORMATION_STATUS
import com.aws.amazonlocation.utils.KEY_COLOR_SCHEMES
import com.aws.amazonlocation.utils.KEY_MAP_STYLE_NAME
import com.aws.amazonlocation.utils.KEY_POLITICAL_VIEW
import com.aws.amazonlocation.utils.KEY_SELECTED_MAP_LANGUAGE
import com.aws.amazonlocation.utils.KEY_UNIT_SYSTEM
import com.aws.amazonlocation.utils.KEY_URL
import com.aws.amazonlocation.utils.KILOMETERS
Expand Down Expand Up @@ -821,6 +822,7 @@ class ExploreFragment :
private fun setMapStyleBottomSheet() {
mViewModel.setMapListData(requireContext())
mViewModel.setPoliticalListData(requireContext())
mViewModel.setMapLanguageData(requireContext())
mapStyleBottomSheetFragment =
MapStyleBottomSheetFragment(
mViewModel,
Expand Down Expand Up @@ -865,6 +867,10 @@ class ExploreFragment :
clearAllMapData()
mMapHelper.updateStyle(mapStyleName, colorScheme)
}

override fun updateMapLanguage() {
mMapLibreMap?.style?.let { mMapHelper.setStyleLanguage(it)}
}
},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.aws.amazonlocation.R
import com.aws.amazonlocation.data.common.DataSourceException
import com.aws.amazonlocation.data.common.HandleResult
import com.aws.amazonlocation.data.response.CalculateDistanceResponse
import com.aws.amazonlocation.data.response.LanguageData
import com.aws.amazonlocation.data.response.MapStyleData
import com.aws.amazonlocation.data.response.MapStyleInnerData
import com.aws.amazonlocation.data.response.NavigationData
Expand Down Expand Up @@ -63,6 +64,7 @@ class ExploreViewModel
var mStyleList = ArrayList<MapStyleData>()
var mPoliticalData = ArrayList<PoliticalData>()
var mPoliticalSearchData = ArrayList<PoliticalData>()
var mMapLanguageData = ArrayList<LanguageData>()

private val _searchForSuggestionsResultList =
Channel<HandleResult<SearchSuggestionResponse>>(Channel.BUFFERED)
Expand Down Expand Up @@ -610,4 +612,81 @@ class ExploreViewModel
it.countryName.contains(query, ignoreCase = true)
})
}

fun setMapLanguageData(context: Context) {
mMapLanguageData.clear()

mMapLanguageData = arrayListOf(
LanguageData(value = context.getString(R.string.label_no_map_language), label = context.getString(R.string.label_no_map_language), isSelected = false),
LanguageData(value = "ar", label = "العربية", isSelected = false),
LanguageData(value = "as", label = "অসমীয়া", isSelected = false),
LanguageData(value = "az", label = "Azərbaycan dili", isSelected = false),
LanguageData(value = "be", label = "Беларуская", isSelected = false),
LanguageData(value = "bg", label = "Български", isSelected = false),
LanguageData(value = "bn", label = "বাংলা", isSelected = false),
LanguageData(value = "bs", label = "Bosanski", isSelected = false),
LanguageData(value = "ca", label = "Català", isSelected = false),
LanguageData(value = "cs", label = "Čeština", isSelected = false),
LanguageData(value = "cy", label = "Cymraeg", isSelected = false),
LanguageData(value = "da", label = "Dansk", isSelected = false),
LanguageData(value = "de", label = "Deutsch", isSelected = false),
LanguageData(value = "el", label = "Ελληνικά", isSelected = false),
LanguageData(value = "en", label = "English", isSelected = false),
LanguageData(value = "es", label = "Español", isSelected = false),
LanguageData(value = "et", label = "Eesti", isSelected = false),
LanguageData(value = "eu", label = "Euskara", isSelected = false),
LanguageData(value = "fi", label = "Suomi", isSelected = false),
LanguageData(value = "fo", label = "Føroyskt", isSelected = false),
LanguageData(value = "fr", label = "Français", isSelected = false),
LanguageData(value = "ga", label = "Gaeilge", isSelected = false),
LanguageData(value = "gl", label = "Galego", isSelected = false),
LanguageData(value = "gn", label = "Avañe'ẽ", isSelected = false),
LanguageData(value = "gu", label = "ગુજરાતી", isSelected = false),
LanguageData(value = "he", label = "עברית", isSelected = false),
LanguageData(value = "hi", label = "हिन्दी", isSelected = false),
LanguageData(value = "hr", label = "Hrvatski", isSelected = false),
LanguageData(value = "hu", label = "Magyar", isSelected = false),
LanguageData(value = "hy", label = "Հայերեն", isSelected = false),
LanguageData(value = "id", label = "Bahasa Indonesia", isSelected = false),
LanguageData(value = "is", label = "Íslenska", isSelected = false),
LanguageData(value = "it", label = "Italiano", isSelected = false),
LanguageData(value = "ja", label = "日本語", isSelected = false),
LanguageData(value = "ka", label = "ქართული", isSelected = false),
LanguageData(value = "kk", label = "Қазақ тілі", isSelected = false),
LanguageData(value = "km", label = "ខ្មែរ", isSelected = false),
LanguageData(value = "kn", label = "ಕನ್ನಡ", isSelected = false),
LanguageData(value = "ko", label = "한국어", isSelected = false),
LanguageData(value = "ky", label = "Кыргызча", isSelected = false),
LanguageData(value = "lt", label = "Lietuvių", isSelected = false),
LanguageData(value = "lv", label = "Latviešu", isSelected = false),
LanguageData(value = "mk", label = "Македонски", isSelected = false),
LanguageData(value = "ml", label = "മലയാളം", isSelected = false),
LanguageData(value = "mr", label = "मराठी", isSelected = false),
LanguageData(value = "ms", label = "Bahasa Melayu", isSelected = false),
LanguageData(value = "mt", label = "Malti", isSelected = false),
LanguageData(value = "my", label = "မြန်မာစာ", isSelected = false),
LanguageData(value = "nl", label = "Nederlands", isSelected = false),
LanguageData(value = "no", label = "Norsk", isSelected = false),
LanguageData(value = "or", label = "ଓଡ଼ିଆ", isSelected = false),
LanguageData(value = "pa", label = "ਪੰਜਾਬੀ", isSelected = false),
LanguageData(value = "pl", label = "Polski", isSelected = false),
LanguageData(value = "pt", label = "Português", isSelected = false),
LanguageData(value = "ro", label = "Română", isSelected = false),
LanguageData(value = "ru", label = "Русский", isSelected = false),
LanguageData(value = "sk", label = "Slovenčina", isSelected = false),
LanguageData(value = "sl", label = "Slovenščina", isSelected = false),
LanguageData(value = "sq", label = "Shqip", isSelected = false),
LanguageData(value = "sr", label = "Српски", isSelected = false),
LanguageData(value = "sv", label = "Svenska", isSelected = false),
LanguageData(value = "ta", label = "தமிழ்", isSelected = false),
LanguageData(value = "te", label = "తెలుగు", isSelected = false),
LanguageData(value = "th", label = "ไทย", isSelected = false),
LanguageData(value = "tr", label = "Türkçe", isSelected = false),
LanguageData(value = "uk", label = "Українська", isSelected = false),
LanguageData(value = "uz", label = "Oʻzbek", isSelected = false),
LanguageData(value = "vi", label = "Tiếng Việt", isSelected = false),
LanguageData(value = "zh", label = "简体中文", isSelected = false),
LanguageData(value = "zh-Hant", label = "繁體中文", isSelected = false)
)
}
}
Loading
Loading