Matvei Malkov | aa33516 | 2019-04-11 19:10:49 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package androidx.ui.material |
| 18 | |
| 19 | import androidx.test.filters.MediumTest |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 20 | import androidx.ui.test.assertHeightIsEqualTo |
Filip Pavlis | 1c5ceb3 | 2019-05-16 15:55:06 +0100 | [diff] [blame] | 21 | import androidx.ui.test.createComposeRule |
Louis Pullen-Freilich | a7eeb10 | 2020-07-22 17:54:24 +0100 | [diff] [blame] | 22 | import androidx.compose.ui.unit.dp |
Filip Pavlis | 1c5ceb3 | 2019-05-16 15:55:06 +0100 | [diff] [blame] | 23 | import org.junit.Rule |
Matvei Malkov | aa33516 | 2019-04-11 19:10:49 +0100 | [diff] [blame] | 24 | import org.junit.Test |
| 25 | import org.junit.runner.RunWith |
| 26 | import org.junit.runners.JUnit4 |
| 27 | |
| 28 | @MediumTest |
| 29 | @RunWith(JUnit4::class) |
Filip Pavlis | 1c5ceb3 | 2019-05-16 15:55:06 +0100 | [diff] [blame] | 30 | class DividerUiTest { |
| 31 | |
| 32 | @get:Rule |
| 33 | val composeTestRule = createComposeRule() |
Matvei Malkov | aa33516 | 2019-04-11 19:10:49 +0100 | [diff] [blame] | 34 | |
Matvei Malkov | aa33516 | 2019-04-11 19:10:49 +0100 | [diff] [blame] | 35 | private val defaultHeight = 1.dp |
| 36 | |
| 37 | @Test |
| 38 | fun divider_DefaultSizes() { |
Matvei Malkov | d91f1f3 | 2019-05-16 14:59:57 +0100 | [diff] [blame] | 39 | composeTestRule |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 40 | .setMaterialContentForSizeAssertions { |
Matvei Malkov | d91f1f3 | 2019-05-16 14:59:57 +0100 | [diff] [blame] | 41 | Divider() |
| 42 | } |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 43 | .assertHeightIsEqualTo(defaultHeight) |
| 44 | .assertWidthFillsRoot() |
Matvei Malkov | aa33516 | 2019-04-11 19:10:49 +0100 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | @Test |
| 48 | fun divider_CustomSizes() { |
Matvei Malkov | aa33516 | 2019-04-11 19:10:49 +0100 | [diff] [blame] | 49 | val height = 20.dp |
Matvei Malkov | d91f1f3 | 2019-05-16 14:59:57 +0100 | [diff] [blame] | 50 | composeTestRule |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 51 | .setMaterialContentForSizeAssertions { |
Anastasia Soboleva | cc1d166 | 2020-03-30 19:38:06 +0100 | [diff] [blame] | 52 | Divider(thickness = height) |
Matvei Malkov | d91f1f3 | 2019-05-16 14:59:57 +0100 | [diff] [blame] | 53 | } |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 54 | .assertWidthFillsRoot() |
| 55 | .assertHeightIsEqualTo(height) |
Matvei Malkov | aa33516 | 2019-04-11 19:10:49 +0100 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | @Test |
| 59 | fun divider_SizesWithIndent_DoesNotChanged() { |
Matvei Malkov | aa33516 | 2019-04-11 19:10:49 +0100 | [diff] [blame] | 60 | val indent = 75.dp |
| 61 | val height = 21.dp |
Matvei Malkov | 0b5d596 | 2019-04-24 13:50:35 +0100 | [diff] [blame] | 62 | |
Matvei Malkov | d91f1f3 | 2019-05-16 14:59:57 +0100 | [diff] [blame] | 63 | composeTestRule |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 64 | .setMaterialContentForSizeAssertions { |
Anastasia Soboleva | cc1d166 | 2020-03-30 19:38:06 +0100 | [diff] [blame] | 65 | Divider(startIndent = indent, thickness = height) |
Louis Pullen-Freilich | 6bc7eac | 2019-04-27 23:50:32 +0100 | [diff] [blame] | 66 | } |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 67 | .assertHeightIsEqualTo(height) |
| 68 | .assertWidthFillsRoot() |
Matvei Malkov | aa33516 | 2019-04-11 19:10:49 +0100 | [diff] [blame] | 69 | } |
| 70 | } |