androidAndroidTest.androidx.constraintlayout.core.PerformanceTest.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ktx-compose-constraint-layout Show documentation
Show all versions of ktx-compose-constraint-layout Show documentation
Extensions for the Kotlin standard library and third-party libraries.
The newest version!
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.constraintlayout.core
import androidx.constraintlayout.core.widgets.ConstraintAnchor
import androidx.constraintlayout.core.widgets.ConstraintWidget
import androidx.constraintlayout.core.widgets.ConstraintWidget.DimensionBehaviour
import androidx.constraintlayout.core.widgets.ConstraintWidgetContainer
import kotlin.test.Test
/**
* Basic performance test
*/
class PerformanceTest {
@Test
fun testBasic() {
val root = ConstraintWidgetContainer(0, 0, 1000, 600)
val A = ConstraintWidget(100, 40)
val B = ConstraintWidget(100, 100)
val C = ConstraintWidget(100, 20)
root.debugName = "root"
A.debugName = "A"
B.debugName = "B"
C.debugName = "C"
root.add(A)
root.add(B)
root.add(C)
A.connect(ConstraintAnchor.Type.LEFT, root, ConstraintAnchor.Type.LEFT)
A.connect(ConstraintAnchor.Type.RIGHT, B, ConstraintAnchor.Type.LEFT)
A.connect(ConstraintAnchor.Type.TOP, root, ConstraintAnchor.Type.TOP)
A.connect(ConstraintAnchor.Type.BOTTOM, C, ConstraintAnchor.Type.TOP)
B.connect(ConstraintAnchor.Type.RIGHT, root, ConstraintAnchor.Type.RIGHT)
B.connect(ConstraintAnchor.Type.TOP, root, ConstraintAnchor.Type.TOP)
C.connect(ConstraintAnchor.Type.LEFT, root, ConstraintAnchor.Type.LEFT)
C.connect(ConstraintAnchor.Type.RIGHT, B, ConstraintAnchor.Type.LEFT)
C.connect(ConstraintAnchor.Type.BOTTOM, root, ConstraintAnchor.Type.BOTTOM)
A.horizontalDimensionBehaviour = DimensionBehaviour.MATCH_CONSTRAINT
C.horizontalDimensionBehaviour = DimensionBehaviour.MATCH_CONSTRAINT
root.layout()
println("root: $root A: $A B: $B C: $C")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy