-
Notifications
You must be signed in to change notification settings - Fork 14
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
fix: [#274] fixing locale on android 14 and setup test using junit & mockk #282
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4c4f99a
chore: [#274] initial setup test using JUnit & MockK
andhikayuana f98eae2
chore: [#274] add more test case at LocaleHelperTest
andhikayuana 21dac06
fix: [#274] fix default language from shared preferences
andhikayuana 0274b85
fix: [#274] disable language split on AAB
andhikayuana 8a219a3
chore: [#274] rename method
andhikayuana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ class IntroLanguageResource { | |
private val EUR: String = "EUR" | ||
private val RMB: String = "RMB" | ||
private val JPY: String = "JPY" | ||
fun loadResources() : Array<IntroLanguage>{ | ||
return arrayOf<IntroLanguage> ( | ||
fun loadResources(): Array<IntroLanguage> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this your linter or just your notice/fix?...I love linter/autoformatters There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, I just using reformat code from Android Studio |
||
return arrayOf<IntroLanguage>( | ||
IntroLanguage( | ||
Language.ENGLISH.code, | ||
Language.ENGLISH.title, | ||
|
@@ -115,4 +115,8 @@ class IntroLanguageResource { | |
) | ||
) | ||
} | ||
|
||
fun findLanguageIndex(language: Language): Int { | ||
return loadResources().map { intro -> intro.lang }.indexOf(language) | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
app/src/test/java/com/breadwallet/tools/util/LocaleHelperTest.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,53 @@ | ||
package com.breadwallet.tools.util | ||
|
||
import android.content.Context | ||
import com.breadwallet.entities.Language | ||
import io.mockk.mockk | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertFalse | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
|
||
class LocaleHelperTest { | ||
|
||
@Test | ||
fun `given LocaleHelper instance, then should validate default value`() { | ||
val context: Context = mockk(relaxed = true) | ||
|
||
LocaleHelper.init(context) | ||
|
||
val currentLocale = LocaleHelper.instance.currentLocale | ||
|
||
assertTrue(currentLocale == Language.ENGLISH) | ||
assertEquals("en", currentLocale.code) | ||
assertEquals("English", currentLocale.title) | ||
assertEquals("Select language", currentLocale.desc) | ||
} | ||
|
||
@Test | ||
fun `getLocale invoked, should return Locale object`() { | ||
val localeIndonesian = LocaleHelper.getLocale(Language.INDONESIAN) | ||
|
||
assertEquals("id", localeIndonesian.language) | ||
|
||
val localeChineseSimplified = LocaleHelper.getLocale(Language.CHINESE_SIMPLIFIED) | ||
|
||
assertEquals("zh", localeChineseSimplified.language) | ||
assertEquals("CN", localeChineseSimplified.country) | ||
} | ||
|
||
@Test | ||
fun `setLocaleIfNeeded invoked, should update current locale`() { | ||
val context: Context = mockk(relaxed = true) | ||
LocaleHelper.init(context) | ||
|
||
val currentLocale = LocaleHelper.instance.currentLocale | ||
assertTrue(currentLocale == Language.ENGLISH) | ||
|
||
var changed = LocaleHelper.instance.setLocaleIfNeeded(Language.INDONESIAN) | ||
assertTrue(changed) | ||
|
||
changed = LocaleHelper.instance.setLocaleIfNeeded(Language.INDONESIAN) | ||
assertFalse(changed) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andhikayuana is this a complex concept. Not familiar with it. Could you briefly explain ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is related with android app bundle concept. in short, when the users download the app from playstore it will only download the specific architecture, specific language
more info https://developer.android.com/guide/app-bundle/configure-base#disable_config_apks