1 /* 2 * Copyright 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.compose.ui.test 18 19 import androidx.compose.ui.test.internal.JvmDefaultWithCompatibility 20 21 /** 22 * Provides the main entry point into testing. 23 * 24 * Typically implemented by a test rule. 25 */ 26 @JvmDefaultWithCompatibility 27 interface SemanticsNodeInteractionsProvider { 28 /** 29 * Finds a semantics node that matches the given condition. 30 * 31 * Any subsequent operation on its result will expect exactly one element found (unless 32 * [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw an [AssertionError] if 33 * none or more than one element is found. 34 * 35 * For usage patterns and semantics concepts see [SemanticsNodeInteraction] 36 * 37 * @param matcher Matcher used for filtering 38 * @param useUnmergedTree If `true`, searches the unmerged semantics tree instead of the merged 39 * semantics tree. This allows you to search for individual nodes that would otherwise be part 40 * of a larger semantic unit, for example a text and an image forming a Button together. 41 * @see onAllNodes to work with multiple elements 42 */ onNodenull43 fun onNode( 44 matcher: SemanticsMatcher, 45 useUnmergedTree: Boolean = false 46 ): SemanticsNodeInteraction 47 48 /** 49 * Finds all semantics nodes that match the given condition. 50 * 51 * If you are working with elements that are not supposed to occur multiple times use [onNode] 52 * instead. 53 * 54 * For usage patterns and semantics concepts see [SemanticsNodeInteraction] 55 * 56 * @param matcher Matcher used for filtering. 57 * @param useUnmergedTree If `true`, searches the unmerged semantics tree instead of the merged 58 * semantics tree. This allows you to search for individual nodes that would otherwise be part 59 * of a larger semantic unit, for example a text and an image forming a Button together. 60 * @see onNode 61 */ 62 fun onAllNodes( 63 matcher: SemanticsMatcher, 64 useUnmergedTree: Boolean = false 65 ): SemanticsNodeInteractionCollection 66 } 67