Skip to content

Commit

Permalink
TECH: Make language features customization easier
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikitae57 committed Nov 5, 2024
1 parent ee04033 commit a83ec0e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -743,10 +748,10 @@ data class Kaspresso(
instrumentalDependencyProviderFactory.getComponentProvider<ExploitImpl>(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()
Expand Down

0 comments on commit a83ec0e

Please sign in to comment.