1 /* 2 * Copyright (C) 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 com.android.car.ui.matchers; 18 19 import android.view.View; 20 21 import com.android.car.ui.matchers.PaddingMatcher.Side; 22 23 import org.hamcrest.Matcher; 24 25 public class ViewMatchers { withDrawable(int drawableId)26 public static Matcher<View> withDrawable(int drawableId) { 27 return new DrawableMatcher(drawableId); 28 } 29 nthChildOfView(Matcher<View> parentMatcher, int n)30 public static Matcher<View> nthChildOfView(Matcher<View> parentMatcher, int n) { 31 return new NthChildMatcher(parentMatcher, n); 32 } 33 withIndex(Matcher<View> matcher, int index)34 public static Matcher<View> withIndex(Matcher<View> matcher, int index) { 35 return new IndexMatcher(matcher, index); 36 } 37 withPadding(Side side, int exactly)38 public static Matcher<View> withPadding(Side side, int exactly) { 39 return new PaddingMatcher(side, exactly, exactly); 40 } 41 withPaddingAtLeast(Side side, int min)42 public static Matcher<View> withPaddingAtLeast(Side side, int min) { 43 return new PaddingMatcher(side, min, -1); 44 } 45 } 46