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.platform 18 19 import android.view.View 20 import androidx.annotation.VisibleForTesting 21 import androidx.compose.ui.node.RootForTest 22 23 /** 24 * The marker interface to be implemented by the [View] backing the composition. To be used in 25 * tests. 26 */ 27 @VisibleForTesting 28 interface ViewRootForTest : RootForTest { 29 30 /** The view backing this Owner. */ 31 val view: View 32 33 /** Returns true when the associated LifecycleOwner is in the resumed state */ 34 val isLifecycleInResumedState: Boolean 35 36 /** Whether the Owner has pending layout work. */ 37 val hasPendingMeasureOrLayout: Boolean 38 39 /** Called to invalidate the Android [View] sub-hierarchy handled by this [View]. */ invalidateDescendantsnull40 fun invalidateDescendants() 41 42 companion object { 43 /** 44 * Called after an View implementing [ViewRootForTest] is created. Used by 45 * AndroidComposeTestRule to keep track of all attached ComposeViews. Not to be set or used 46 * by any other component. 47 */ 48 @VisibleForTesting var onViewCreatedCallback: ((ViewRootForTest) -> Unit)? = null 49 } 50 } 51