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
/* Copyright 2024 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).apply { | |
executeShellCommand( | |
"cmd overlay enable-exclusive " + | |
"com.android.internal.systemui.navbar.gestural", // or .threebutton | |
) | |
} |
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
plugins { | |
... | |
jacoco | |
} | |
android { | |
applicationVariants.all(closureOf<com.android.build.gradle.api.ApplicationVariant> { | |
val myObjFactory = project.objects | |
val buildDir = layout.buildDirectory.get().asFile |
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
/* | |
* Copyright 2023 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* https://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
fun waitUntilAtLeastOneExists(matcher: SemanticsMatcher, timeout: Long = 1000L) | |
fun waitUntilDoesNotExist(matcher: SemanticsMatcher, timeout: Long = 1000L) | |
fun waitUntilExactlyOneExists(matcher: SemanticsMatcher, timeout: Long = 1000L) | |
fun waitUntilNodeCount(matcher: SemanticsMatcher, count: Int, timeout: Long = 1000L) |
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
#!/bin/bash | |
# | |
# Copyright (C) 2022 The Android Open Source Project | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |
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
@Test | |
fun loginScreen_onContinueClick_welcomeDisplayed() { | |
composeTestRule.onNodeWithText("Continue¨).performClick() | |
composeTestRule.waitUntilDoesNotExist(hasText("Loading")) | |
composeTestRule.onNodeWithText("Welcome").assertExists() | |
} |
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
@Test | |
fun loginScreen_onContinueClick_welcomeDisplayed() { | |
composeTestRule.onNodeWithText("Continue¨).performClick() | |
// Screen still shows "Loading" | |
composeTestRule.onNodeWithText("Welcome").assertExists() // FAILS! | |
} |
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 MyViewModel(repository…) { | |
val data = flow{ | |
... | |
emitAll(repository.observeData()) | |
} | |
} |
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
@Composable | |
fun MyScreen(val viewModel: MyViewModel = viewModel()) { | |
val data by viewModel.data.collectAsState("Loading") | |
Text(greeting) | |
} |
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
composeTestRule.waitUntilExactlyOneExists(hasText("Continue")) |
NewerOlder