Skip to content

Commit

Permalink
codestyle: Companion objects
Browse files Browse the repository at this point in the history
Signed-off-by: Ruslan Mingaliev <mingaliev.rr@gmail.com>
  • Loading branch information
RuslanMingaliev committed Jan 9, 2020
1 parent 10f1e2b commit ba0de8b
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.kaspersky.kaspresso.logger.UiTestLogger
internal class ActivityMetadata(
private val logger: UiTestLogger
) {

companion object {
private const val INDEX_SEPARATOR = '_'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class AppsImpl(
) : Apps {

companion object {

const val LAUNCH_RECENT_TIMEOUT = 1_000L
const val LAUNCH_APP_TIMEOUT = 5_000L
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import java.util.Locale
internal class Locales(
private val logger: UiTestLogger
) {

companion object {
private const val LOCALES_ARG = "localizations"
private const val LANGUAGE_COUNTRY_SEPARATOR = "-"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import java.io.File
internal class ScreenshotFiles(
private val screenshotDir: File
) {

companion object {
private const val NAME_SEPARATOR = "_"
private const val EXTENSION = ".png"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import java.util.concurrent.CountDownLatch
internal class InternalScreenshotMaker(
private val screenshotFiles: ScreenshotFiles
) {

companion object {
const val PICTURE_QUALITY = 100
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal class DocLocScreenshotCapturer(
private val activities: Activities,
private val apps: Apps
) {

private companion object {
private const val SCREENSHOT_CAPTURE_DELAY_MS: Long = 500
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ data class Kaspresso(
internal val stepWatcherInterceptors: List<StepWatcherInterceptor>,
internal val testRunWatcherInterceptors: List<TestRunWatcherInterceptor>
) {

private companion object {
private const val DEFAULT_LIB_LOGGER_TAG: String = "KASPRESSO"
private const val DEFAULT_TEST_LOGGER_TAG: String = "KASPRESSO_TEST"
Expand Down Expand Up @@ -521,7 +522,7 @@ data class Kaspresso(
if (!::language.isInitialized) language = LanguageImpl(libLogger, instrumentation.targetContext)

if (!::flakySafetyParams.isInitialized) flakySafetyParams = FlakySafetyParams.kakaoInstance()
if (!::kautomatorFlakySafetyParams.isInitialized) kautomatorFlakySafetyParams = FlakySafetyParams.uiAutomatorDslInstance()
if (!::kautomatorFlakySafetyParams.isInitialized) kautomatorFlakySafetyParams = FlakySafetyParams.kautomatorInstance()
if (!::continuouslyParams.isInitialized) continuouslyParams = ContinuouslyParams()
if (!::autoScrollParams.isInitialized) autoScrollParams = AutoScrollParams()
if (!::stepParams.isInitialized) stepParams = StepParams()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ContinuouslyParams(
timeoutMs: Long = DEFAULT_TIMEOUT_MS,
intervalMs: Long = DEFAULT_INTERVAL_MS
) {

private companion object {
private const val DEFAULT_TIMEOUT_MS: Long = 5_000L
private const val DEFAULT_INTERVAL_MS: Long = 500L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FlakySafetyParams private constructor(
*/
val allowedExceptions: Set<Class<out Throwable>>
) {

companion object {
fun kakaoInstance(): FlakySafetyParams {
return FlakySafetyParams(
Expand All @@ -33,7 +34,7 @@ class FlakySafetyParams private constructor(
)
}

fun uiAutomatorDslInstance(): FlakySafetyParams {
fun kautomatorInstance(): FlakySafetyParams {
return FlakySafetyParams(
timeoutMs = 15_000L,
intervalMs = 1_000L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import java.util.LinkedList
@KautomatorMarker
open class UiScreen<out T : UiScreen<T>> : UiScreenActions {

companion object {
internal val UI_OBJECT_INTERCEPTORS: Deque<UiInterceptor<UiObjectInteraction, UiObjectAssertion, UiObjectAction>> = LinkedList()
internal val UI_DEVICE_INTERCEPTORS: Deque<UiInterceptor<UiDeviceInteraction, UiDeviceAssertion, UiDeviceAction>> = LinkedList()
}

override val view: UiDeviceDelegate = UiDeviceDelegate(
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
)
Expand Down Expand Up @@ -111,9 +116,4 @@ open class UiScreen<out T : UiScreen<T>> : UiScreenActions {
uiObjectInterceptor?.let { UI_OBJECT_INTERCEPTORS.removeFirstOccurrence(it) }
uiDeviceInterceptor?.let { UI_DEVICE_INTERCEPTORS.removeFirstOccurrence(it) }
}

companion object {
internal val UI_OBJECT_INTERCEPTORS: Deque<UiInterceptor<UiObjectInteraction, UiObjectAssertion, UiObjectAction>> = LinkedList()
internal val UI_DEVICE_INTERCEPTORS: Deque<UiInterceptor<UiDeviceInteraction, UiDeviceAssertion, UiDeviceAction>> = LinkedList()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import kotlinx.android.synthetic.main.activity_simple.*
class SimpleActivity : AppCompatActivity() {

companion object {

const val TAG = "SimpleActivity"
private const val TIMEOUT: Long = 2000
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class UpgradeTestSample : UpgradeTestCase() {
intercept {
onUiInteraction {
onCheck { uiInteraction, uiAssert ->
testLogger.i("UIA", "type=${uiAssert.getType()}, description=${uiAssert.getDescription()}")
testLogger.i("UIA", "type=${uiAssert.type}, description=${uiAssert.description}")
}
onPerform { uiInteraction, uiAction ->
testLogger.i("UIA", "type=${uiAction.getType()}, description=${uiAction.getDescription()}")
testLogger.i("UIA", "type=${uiAction.type}, description=${uiAction.description}")
}
}
}
Expand Down

0 comments on commit ba0de8b

Please sign in to comment.