1 /*
<lambda>null2  * Copyright 2024 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.foundation.text.test
18 
19 import androidx.compose.ui.unit.IntRect
20 import com.google.common.truth.Fact.simpleFact
21 import com.google.common.truth.FailureMetadata
22 import com.google.common.truth.Subject
23 import com.google.common.truth.Subject.Factory
24 import com.google.common.truth.Truth.assertAbout
25 
26 internal fun assertThatIntRect(rect: IntRect?): IntRectSubject {
27     return assertAbout(IntRectSubject.SUBJECT_FACTORY).that(rect)!!
28 }
29 
30 internal class IntRectSubject
31 private constructor(failureMetadata: FailureMetadata?, private val subject: IntRect?) :
32     Subject(failureMetadata, subject) {
33     companion object {
34         internal val SUBJECT_FACTORY: Factory<IntRectSubject?, IntRect?> =
subjectnull35             Factory { failureMetadata, subject ->
36                 IntRectSubject(failureMetadata, subject)
37             }
38     }
39 
isEqualTonull40     fun isEqualTo(left: Int, top: Int, right: Int, bottom: Int) {
41         if (subject == null) failWithoutActual(simpleFact("is null"))
42         check("instanceOf()").that(subject!!).isInstanceOf(IntRect::class.java)
43         check("left").that(subject.left).isEqualTo(left)
44         check("top").that(subject.top).isEqualTo(top)
45         check("right").that(subject.right).isEqualTo(right)
46         check("bottom").that(subject.bottom).isEqualTo(bottom)
47     }
48 }
49