[go: nahoru, domu]

blob: fe3df3d48ca26da615b8d210b96e1503cd9b4400 [file] [log] [blame]
Matvei Malkovaa335162019-04-11 19:10:49 +01001/*
2 * Copyright 2019 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
17package androidx.ui.material
18
19import androidx.test.filters.MediumTest
Filip Pavlis028c0d52020-06-29 15:07:53 +010020import androidx.ui.test.assertHeightIsEqualTo
Filip Pavlis1c5ceb32019-05-16 15:55:06 +010021import androidx.ui.test.createComposeRule
Louis Pullen-Freilicha7eeb102020-07-22 17:54:24 +010022import androidx.compose.ui.unit.dp
Filip Pavlis1c5ceb32019-05-16 15:55:06 +010023import org.junit.Rule
Matvei Malkovaa335162019-04-11 19:10:49 +010024import org.junit.Test
25import org.junit.runner.RunWith
26import org.junit.runners.JUnit4
27
28@MediumTest
29@RunWith(JUnit4::class)
Filip Pavlis1c5ceb32019-05-16 15:55:06 +010030class DividerUiTest {
31
32 @get:Rule
33 val composeTestRule = createComposeRule()
Matvei Malkovaa335162019-04-11 19:10:49 +010034
Matvei Malkovaa335162019-04-11 19:10:49 +010035 private val defaultHeight = 1.dp
36
37 @Test
38 fun divider_DefaultSizes() {
Matvei Malkovd91f1f32019-05-16 14:59:57 +010039 composeTestRule
Filip Pavlis028c0d52020-06-29 15:07:53 +010040 .setMaterialContentForSizeAssertions {
Matvei Malkovd91f1f32019-05-16 14:59:57 +010041 Divider()
42 }
Filip Pavlis028c0d52020-06-29 15:07:53 +010043 .assertHeightIsEqualTo(defaultHeight)
44 .assertWidthFillsRoot()
Matvei Malkovaa335162019-04-11 19:10:49 +010045 }
46
47 @Test
48 fun divider_CustomSizes() {
Matvei Malkovaa335162019-04-11 19:10:49 +010049 val height = 20.dp
Matvei Malkovd91f1f32019-05-16 14:59:57 +010050 composeTestRule
Filip Pavlis028c0d52020-06-29 15:07:53 +010051 .setMaterialContentForSizeAssertions {
Anastasia Sobolevacc1d1662020-03-30 19:38:06 +010052 Divider(thickness = height)
Matvei Malkovd91f1f32019-05-16 14:59:57 +010053 }
Filip Pavlis028c0d52020-06-29 15:07:53 +010054 .assertWidthFillsRoot()
55 .assertHeightIsEqualTo(height)
Matvei Malkovaa335162019-04-11 19:10:49 +010056 }
57
58 @Test
59 fun divider_SizesWithIndent_DoesNotChanged() {
Matvei Malkovaa335162019-04-11 19:10:49 +010060 val indent = 75.dp
61 val height = 21.dp
Matvei Malkov0b5d5962019-04-24 13:50:35 +010062
Matvei Malkovd91f1f32019-05-16 14:59:57 +010063 composeTestRule
Filip Pavlis028c0d52020-06-29 15:07:53 +010064 .setMaterialContentForSizeAssertions {
Anastasia Sobolevacc1d1662020-03-30 19:38:06 +010065 Divider(startIndent = indent, thickness = height)
Louis Pullen-Freilich6bc7eac2019-04-27 23:50:32 +010066 }
Filip Pavlis028c0d52020-06-29 15:07:53 +010067 .assertHeightIsEqualTo(height)
68 .assertWidthFillsRoot()
Matvei Malkovaa335162019-04-11 19:10:49 +010069 }
70}