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
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.tooling.preview.Preview | |
@Composable | |
fun Widget(name: String) { | |
// UI code... | |
} | |
@Preview | |
@Composable |
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
infix fun openSearch(block: SearchToolbar.() -> Unit): SearchToolbar { | |
// Testing framework code | |
return SearchToolbar.apply(block) | |
} |
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
fun toolbar(block: Toolbar.() -> Unit): Toolbar = Toolbar.apply(block) | |
object Toolbar { | |
fun openSearch(block: SearchToolbar.() -> Unit): SearchToolbar { | |
// Testing framework code | |
return SearchToolbar.apply(block) | |
} | |
} |
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
val searchQuery = "foo" | |
toolbar { | |
}. openSearch() { | |
type(searchQuery) | |
} |
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
val searchQuery = "foo" | |
toolbar { | |
} openSearch { | |
type(searchQuery) | |
} |
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
fun navigation(block: NavController.() -> Unit): Unit = NavController.block() | |
object NavController { | |
fun openScreenOne() { | |
// Testing framework code | |
} | |
} |
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
class SearchTest : UITest() { | |
@Before | |
fun setup() { | |
navigation { | |
openScreenOne() | |
} | |
} | |
@Test |
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
verticalLayout { | |
val name = editText() | |
button("Say Hello") { | |
onClick { | |
toast("Hello, ${name.text}!") | |
} | |
} | |
} |
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
class Component : ComponentInterface { | |
private val navigable: Navigable = NavigableImpl() | |
private val searchable: Searchable = SearchableImpl() | |
override val onNavigationClick by ref(navigable::onNavigationClick) | |
override var searchText by ref(searchable::searchText) | |
} |
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
class ReferencedProperty<T>(private val get: () -> T, | |
private val set: (T) -> Unit = {}) { | |
operator fun getValue(thisRef: Any?, | |
property: KProperty<*>): T = get() | |
operator fun setValue(thisRef: Any?, | |
property: KProperty<*>, | |
value: T) = set(value) | |
} |
NewerOlder