Skip to content

Instantly share code, notes, and snippets.

@AlexZhukovich
AlexZhukovich / Appium-vs-Espresso-vs-UiAutomator.csv
Last active November 23, 2022 09:26
Appium vs Espresso vs UiAutomator - Summary
Criteria Appium Espresso UiAutomator
Execution Time Slow (test case: 12.154 sec) Fast (test case: 0.967 sec) Medium (test case: 8.743 sec)
Supported languages Java, Kotlin, C#, JavaScript, Python, Ruby Java, Kotlin Java, Kotlin
Test Type Black Box Gray Box Black Box
Setup Hard (separate module, capabilities (device, app, etc.)) Easy (part of the project) Easy (part of the project)
@AlexZhukovich
AlexZhukovich / Analytics.kt
Last active October 6, 2022 14:23
Android ProcessLifecycleOwner 
by example - source code for article https://alexzh.com/2019/08/19/android-processlifecycleowner-by-example/
class Analytics {
private var startSessionTimestamp: Long = -1
private val reporters = mutableListOf<AnalyticsReporter>()
fun addReporter(reporter: AnalyticsReporter) {
reporters.add(reporter)
}
fun startSession() {
startSessionTimestamp = Date().time
@AlexZhukovich
AlexZhukovich / README.md
Last active September 21, 2021 07:04
Testing redirect with Cypress

This gist shows how to create a Cypress test case that verifies redirect.

In the current example, the redirect-data.json has only one object. However, you can add more objects.

Article: https://alexzh.com/testing-redirect-with-cypress/

File pathes:

  • cypress/fixtures/redirect-data.json
  • cypress/integration/website-redirect/website-redirect.spec.js
@AlexZhukovich
AlexZhukovich / DemoAlignModifier.kt
Created March 7, 2021 12:54
Jetpack Compose: Layouts
package com.alexzh.composeplayground
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
@AlexZhukovich
AlexZhukovich / customRange.kt
Created November 20, 2020 07:36
Kotlin: Custom Range - Restaurant delivery time options
data class Restaurant(
val id: Long,
val name: String,
val openTime: Date,
val closeTime: Date
) {
private val deliveryTimeStep: Long = 15 * 60 * 1000
fun getDeliveryTimeOptions(): DeliveryTimeOptions {
return openTime..closeTime step deliveryTimeStep
package com.alexzh.recyclerviewsetemptyview;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
public class EmptyRecyclerView extends RecyclerView {
private View mEmptyView;
@AlexZhukovich
AlexZhukovich / gist:084fcf7d89e1080d574b62eb25b5a79b
Created February 7, 2020 12:17
Jetpack Compose - combine composable functions
@Composable
fun CoffeeDrinkCard(
coffeeDrink: CoffeeDrinkModel
) {
MaterialTheme {
Column {
Row {
CoffeeDrinkLogo(id = coffeeDrink.imageUrl)
Container(alignment = Alignment.TopLeft,modifier = LayoutFlexible(1f)) {
Column {
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
CoffeeDrinksList(coffeeDrinks)
}
}
@Composable
fun CoffeeDrinkList(
coffeeDrinks: List<CoffeeDrink>
@Composable
fun CoffeeDrinkCard(
coffeeDrink: CoffeeDrinkModel
) {
Row {
Container(modifier = LayoutSize(80.dp), alignment = Alignment.Center) {
DrawImage(image = imageResource(coffeeDrink.imageUrl))
}
Container(
alignment = Alignment.TopLeft,
fun getCoffeeDrinks(): List<CoffeeDrink> {
return listOf(
CoffeeDrink(
name = "Americano",
imageUrl = R.drawable.americano_small,
ingredients = "Espresso, Water"
),
CoffeeDrink(
name = "Cappuccino",
imageUrl = R.drawable.cappuccino_small,