• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 android.tools.common.flicker.subject.region
18 
19 import android.tools.common.datatypes.Rect
20 import android.tools.common.datatypes.Region
21 import android.tools.common.flicker.subject.exceptions.IncorrectRegionException
22 
23 interface IRegionSubject {
24     /**
25      * Asserts that the top and bottom coordinates of [other] are smaller or equal to those of
26      * region.
27      *
28      * Also checks that the left and right positions, as well as area, don't change
29      *
30      * @throws IncorrectRegionException
31      */
isHigherOrEqualnull32     fun isHigherOrEqual(other: Rect): IRegionSubject
33 
34     /**
35      * Asserts that the top and bottom coordinates of [other] are smaller or equal to those of
36      * region.
37      *
38      * Also checks that the left and right positions, as well as area, don't change
39      *
40      * @throws IncorrectRegionException
41      */
42     fun isHigherOrEqual(other: Region): IRegionSubject
43 
44     /**
45      * Asserts that the top and bottom coordinates of [other] are greater or equal to those of
46      * region.
47      *
48      * Also checks that the left and right positions, as well as area, don't change
49      *
50      * @throws IncorrectRegionException
51      */
52     fun isLowerOrEqual(other: Rect): IRegionSubject
53 
54     /**
55      * Asserts that the top and bottom coordinates of [other] are greater or equal to those of
56      * region.
57      *
58      * Also checks that the left and right positions, as well as area, don't change
59      *
60      * @throws AssertionError
61      */
62     fun isLowerOrEqual(other: Region): IRegionSubject
63 
64     /**
65      * Asserts that the left and right coordinates of [other] are lower or equal to those of region.
66      *
67      * Also checks that the top and bottom positions, as well as area, don't change
68      *
69      * @throws AssertionError
70      */
71     fun isToTheRight(other: Region): IRegionSubject
72 
73     /**
74      * Asserts that the top and bottom coordinates of [other] are smaller than those of region.
75      *
76      * Also checks that the left and right positions, as well as area, don't change
77      *
78      * @throws AssertionError
79      */
80     fun isHigher(other: Rect): IRegionSubject
81 
82     /**
83      * Asserts that the top and bottom coordinates of [other] are smaller than those of region.
84      *
85      * Also checks that the left and right positions, as well as area, don't change
86      *
87      * @throws AssertionError
88      */
89     fun isHigher(other: Region): IRegionSubject
90 
91     /**
92      * Asserts that the top and bottom coordinates of [other] are greater than those of region.
93      *
94      * Also checks that the left and right positions, as well as area, don't change
95      *
96      * @throws AssertionError
97      */
98     fun isLower(other: Rect): IRegionSubject
99 
100     /**
101      * Asserts that the top and bottom coordinates of [other] are greater than those of region.
102      *
103      * Also checks that the left and right positions, as well as area, don't change
104      *
105      * @throws AssertionError
106      */
107     fun isLower(other: Region): IRegionSubject
108 
109     /**
110      * Asserts that region covers at most [other], that is, its area doesn't cover any point outside
111      * of [other].
112      *
113      * @param other Expected covered area
114      * @throws AssertionError
115      */
116     fun coversAtMost(other: Region): IRegionSubject
117 
118     /**
119      * Asserts that region covers at most [other], that is, its area doesn't cover any point outside
120      * of [other].
121      *
122      * @param other Expected covered area
123      * @throws AssertionError
124      */
125     fun coversAtMost(other: Rect): IRegionSubject
126 
127     /**
128      * Asserts that region is not bigger than [other], even if the regions don't overlap.
129      *
130      * @param other Area to compare to
131      * @throws AssertionError
132      */
133     fun notBiggerThan(other: Region): IRegionSubject
134 
135     /**
136      * Asserts that region is positioned to the right and bottom from [other], but the regions can
137      * overlap and region can be smaller than [other]
138      *
139      * @param other Area to compare to
140      * @param threshold Offset threshold by which the position might be off
141      * @throws AssertionError
142      */
143     fun isToTheRightBottom(other: Region, threshold: Int): IRegionSubject
144 
145     /**
146      * Asserts that region covers at least [other], that is, its area covers each point in the
147      * region
148      *
149      * @param other Expected covered area
150      * @throws AssertionError
151      */
152     fun coversAtLeast(other: Region): IRegionSubject
153 
154     /**
155      * Asserts that region covers at least [other], that is, its area covers each point in the
156      * region
157      *
158      * @param other Expected covered area
159      * @throws AssertionError
160      */
161     fun coversAtLeast(other: Rect): IRegionSubject
162 
163     /**
164      * Asserts that region covers at exactly [other]
165      *
166      * @param other Expected covered area
167      * @throws AssertionError
168      */
169     fun coversExactly(other: Region): IRegionSubject
170 
171     /**
172      * Asserts that region covers at exactly [other]
173      *
174      * @param other Expected covered area
175      * @throws AssertionError
176      */
177     fun coversExactly(other: Rect): IRegionSubject
178 
179     /**
180      * Asserts that region and [other] overlap
181      *
182      * @param other Other area
183      * @throws AssertionError
184      */
185     fun overlaps(other: Region): IRegionSubject
186 
187     /**
188      * Asserts that region and [other] overlap
189      *
190      * @param other Other area
191      * @throws AssertionError
192      */
193     fun overlaps(other: Rect): IRegionSubject
194 
195     /**
196      * Asserts that region and [other] don't overlap
197      *
198      * @param other Other area
199      * @throws AssertionError
200      */
201     fun notOverlaps(other: Region): IRegionSubject
202 
203     /**
204      * Asserts that region and [other] don't overlap
205      *
206      * @param other Other area
207      * @throws AssertionError
208      */
209     fun notOverlaps(other: Rect): IRegionSubject
210 
211     /**
212      * Asserts that region and [other] have same aspect ratio, margin of error up to 0.1.
213      *
214      * @param other Other region
215      * @throws AssertionError
216      */
217     fun isSameAspectRatio(other: Region, threshold: Double): IRegionSubject
218 }
219