diff --git a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/device/languages/LanguageImpl.kt b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/device/languages/LanguageImpl.kt index 557961ade..76c9a9ad6 100644 --- a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/device/languages/LanguageImpl.kt +++ b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/device/languages/LanguageImpl.kt @@ -16,7 +16,7 @@ import java.util.Locale /** * The implementation of [Language] */ -internal class LanguageImpl( +open class LanguageImpl( private val logger: UiTestLogger, private val instrumentation: Instrumentation, private val systemLanguage: SystemLanguage, diff --git a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/docloc/SystemLanguage.kt b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/docloc/SystemLanguage.kt index 8eb4aaff9..6cbb768ef 100644 --- a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/docloc/SystemLanguage.kt +++ b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/docloc/SystemLanguage.kt @@ -10,7 +10,7 @@ import com.kaspersky.kaspresso.device.permissions.HackPermissions import com.kaspersky.kaspresso.logger.UiTestLogger import java.util.Locale -internal class SystemLanguage( +open class SystemLanguage( private val context: Context, private val logger: UiTestLogger, private val hackPermissions: HackPermissions @@ -24,7 +24,7 @@ internal class SystemLanguage( * @throws Throwable if something went wrong */ @SuppressLint("PrivateApi", "DiscouragedPrivateApi") - fun switch(locale: Locale) { + open fun switch(locale: Locale) { logger.i("SystemLanguage: Installing new system language=$locale started") grantPermissionsIfNeed() try { diff --git a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/kaspresso/Kaspresso.kt b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/kaspresso/Kaspresso.kt index 9a17041db..dd139dcf9 100644 --- a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/kaspresso/Kaspresso.kt +++ b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/kaspresso/Kaspresso.kt @@ -426,6 +426,11 @@ data class Kaspresso( */ lateinit var exploit: Exploit + /** + * Holds an implementation of [SystemLanguage] interface. If it was not specified, the default implementation is used. + */ + lateinit var systemLanguage: SystemLanguage + /** * Holds an implementation of [Language] interface. If it was not specified, the default implementation is used. */ @@ -743,10 +748,10 @@ data class Kaspresso( instrumentalDependencyProviderFactory.getComponentProvider(instrumentation), adbServer ) - if (!::language.isInitialized) { - val systemLanguage = SystemLanguage(instrumentation.targetContext, testLogger, hackPermissions) - language = LanguageImpl(libLogger, instrumentation, systemLanguage) - } + + if (!::systemLanguage.isInitialized) systemLanguage = SystemLanguage(instrumentation.targetContext, testLogger, hackPermissions) + if (!::language.isInitialized) language = LanguageImpl(libLogger, instrumentation, systemLanguage) + if (!::logcat.isInitialized) logcat = LogcatImpl(libLogger, adbServer) if (!::flakySafetyParams.isInitialized) flakySafetyParams = FlakySafetyParams.default()