importandroidx.test.uiautomator.UiObjectimportorg.junit.Assert.assertTruefunUiObject.performClick():UiObject{assertTrue("Clicking UiObject",click())returnthis}funUiObject.verifyVisible(timeout:Long=0):UiObject{assertTrue("View is Visible",waitForExists(timeout))returnthis}
fungetFriendlyBottomSheetBehaviorStateDescription(state:Int):String=when(state){BottomSheetBehavior.STATE_DRAGGING->"dragging"BottomSheetBehavior.STATE_SETTLING->"settling"BottomSheetBehavior.STATE_EXPANDED->"expanded"BottomSheetBehavior.STATE_COLLAPSED->"collapsed"BottomSheetBehavior.STATE_HIDDEN->"hidden"BottomSheetBehavior.STATE_HALF_EXPANDED->"half-expanded"else->"unknown but the value was $state"}funhasBottomSheetBehaviorState(expectedState:Int):Matcher<inView>?{returnobject:BoundedMatcher<View,View>(View::class.java){overridefundescribeTo(description:Description){description.appendText("has BottomSheetBehavior state: ${getFriendlyBottomSheetBehaviorStateDescription(expectedState)}")}overridefunmatchesSafely(view:View):Boolean{valbottomSheetBehavior=BottomSheetBehavior.from(view)returnexpectedState==bottomSheetBehavior.state}}}funhasBottomSheetBehaviorState(expectedState:Int):Matcher<inView>?{returnobject:BoundedMatcher<View,View>(View::class.java){overridefundescribeTo(description:Description){description.appendText("has BottomSheetBehavior state $expectedState")}overridefunmatchesSafely(view:View):Boolean{valbottomSheetBehavior=BottomSheetBehavior.from(view)returnexpectedState==bottomSheetBehavior.state}}}