Skip to content

Commit 194663d

Browse files
committed
Add snapshots for list items and card items
# Conflicts: # core-test/src/main/java/com/orange/ouds/core/test/OudsComponentTestSuite.kt # core/src/main/java/com/orange/ouds/core/utilities/OudsPreviewableComponent.kt
1 parent d627838 commit 194663d

218 files changed

Lines changed: 499 additions & 68 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Software Name: OUDS Android
3+
* SPDX-FileCopyrightText: Copyright (c) Orange SA
4+
* SPDX-License-Identifier: MIT
5+
*
6+
* This software is distributed under the MIT license,
7+
* the text of which is available at https://opensource.org/license/MIT/
8+
* or see the "LICENSE" file for more details.
9+
*
10+
* Software description: Android library of reusable graphical components
11+
*/
12+
13+
package com.orange.ouds.core.test
14+
15+
import com.orange.ouds.core.utilities.OudsPreviewableComponent
16+
import org.junit.experimental.runners.Enclosed
17+
import org.junit.runner.RunWith
18+
import org.junit.runners.Parameterized
19+
20+
@RunWith(Enclosed::class)
21+
internal class OudsCardItemTest {
22+
23+
@RunWith(Parameterized::class)
24+
class Static(parameter: Any) : OudsComponentSnapshotTest(
25+
OudsPreviewableComponent.CardItem.Static,
26+
parameter,
27+
OudsComponentTestSuite.theme
28+
) {
29+
30+
companion object {
31+
@JvmStatic
32+
@Parameterized.Parameters
33+
internal fun data() = OudsPreviewableComponent.CardItem.Static.parameters
34+
}
35+
}
36+
37+
class StaticWithRoundedCorners : OudsComponentSnapshotTest(
38+
OudsPreviewableComponent.CardItem.StaticWithRoundedCorners,
39+
parameter = null,
40+
OudsComponentTestSuite.theme
41+
)
42+
43+
@RunWith(Parameterized::class)
44+
class Navigation(parameter: Any) : OudsComponentSnapshotTest(
45+
OudsPreviewableComponent.CardItem.Navigation,
46+
parameter,
47+
OudsComponentTestSuite.theme,
48+
heightDp = OudsPreviewableComponent.CardItem.Navigation.PreviewHeightDp
49+
) {
50+
51+
companion object {
52+
@JvmStatic
53+
@Parameterized.Parameters
54+
internal fun data() = OudsPreviewableComponent.CardItem.Navigation.parameters
55+
}
56+
}
57+
58+
class NavigationWithRoundedCorners : OudsComponentSnapshotTest(
59+
OudsPreviewableComponent.CardItem.NavigationWithRoundedCorners,
60+
parameter = null,
61+
OudsComponentTestSuite.theme,
62+
heightDp = OudsPreviewableComponent.CardItem.Navigation.PreviewHeightDp
63+
)
64+
}

core-test/src/main/java/com/orange/ouds/core/test/OudsComponentTestSuite.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.junit.runners.Suite
2323
OudsBottomSheetScaffoldTest::class,
2424
OudsBulletListTest::class,
2525
OudsButtonTest::class,
26+
OudsCardItemTest::class,
2627
OudsCheckboxItemTest::class,
2728
OudsCheckboxTest::class,
2829
OudsCircularProgressIndicatorTest::class,
@@ -34,6 +35,7 @@ import org.junit.runners.Suite
3435
OudsInputTagTest::class,
3536
OudsLinearProgressIndicatorTest::class,
3637
OudsLinkTest::class,
38+
OudsListItemTest::class,
3739
OudsModalBottomSheetTest::class,
3840
OudsNavigationBarTest::class,
3941
OudsNavigationBarItemTest::class,
@@ -43,6 +45,8 @@ import org.junit.runners.Suite
4345
OudsRadioButtonItemTest::class,
4446
OudsRadioButtonTest::class,
4547
OudsSmallButtonTest::class,
48+
OudsSmallCardItemTest::class,
49+
OudsSmallListItemTest::class,
4650
OudsSuggestionChipTest::class,
4751
OudsSwitchItemTest::class,
4852
OudsSwitchTest::class,
@@ -51,8 +55,9 @@ import org.junit.runners.Suite
5155
OudsTextInputTest::class,
5256
OudsTopAppBarTest::class
5357
)
54-
abstract class OudsComponentTestSuite {
5558

59+
abstract class OudsComponentTestSuite {
60+
5661
companion object {
5762
lateinit var theme: OudsThemeContract
5863
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Software Name: OUDS Android
3+
* SPDX-FileCopyrightText: Copyright (c) Orange SA
4+
* SPDX-License-Identifier: MIT
5+
*
6+
* This software is distributed under the MIT license,
7+
* the text of which is available at https://opensource.org/license/MIT/
8+
* or see the "LICENSE" file for more details.
9+
*
10+
* Software description: Android library of reusable graphical components
11+
*/
12+
13+
package com.orange.ouds.core.test
14+
15+
import com.orange.ouds.core.utilities.OudsPreviewableComponent
16+
import org.junit.experimental.runners.Enclosed
17+
import org.junit.runner.RunWith
18+
import org.junit.runners.Parameterized
19+
20+
@RunWith(Enclosed::class)
21+
internal class OudsListItemTest {
22+
23+
@RunWith(Parameterized::class)
24+
class Static(parameter: Any) : OudsComponentSnapshotTest(
25+
OudsPreviewableComponent.ListItem.Static,
26+
parameter,
27+
OudsComponentTestSuite.theme
28+
) {
29+
30+
companion object {
31+
@JvmStatic
32+
@Parameterized.Parameters
33+
internal fun data() = OudsPreviewableComponent.ListItem.Static.parameters
34+
}
35+
}
36+
37+
@RunWith(Parameterized::class)
38+
class Navigation(parameter: Any) : OudsComponentSnapshotTest(
39+
OudsPreviewableComponent.ListItem.Navigation,
40+
parameter,
41+
OudsComponentTestSuite.theme,
42+
heightDp = OudsPreviewableComponent.ListItem.Navigation.PreviewHeightDp
43+
) {
44+
45+
companion object {
46+
@JvmStatic
47+
@Parameterized.Parameters
48+
internal fun data() = OudsPreviewableComponent.ListItem.Navigation.parameters
49+
}
50+
}
51+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Software Name: OUDS Android
3+
* SPDX-FileCopyrightText: Copyright (c) Orange SA
4+
* SPDX-License-Identifier: MIT
5+
*
6+
* This software is distributed under the MIT license,
7+
* the text of which is available at https://opensource.org/license/MIT/
8+
* or see the "LICENSE" file for more details.
9+
*
10+
* Software description: Android library of reusable graphical components
11+
*/
12+
13+
package com.orange.ouds.core.test
14+
15+
import com.orange.ouds.core.utilities.OudsPreviewableComponent
16+
import org.junit.experimental.runners.Enclosed
17+
import org.junit.runner.RunWith
18+
import org.junit.runners.Parameterized
19+
20+
@RunWith(Enclosed::class)
21+
internal class OudsSmallCardItemTest {
22+
23+
@RunWith(Parameterized::class)
24+
class Static(parameter: Any) : OudsComponentSnapshotTest(
25+
OudsPreviewableComponent.SmallCardItem.Static,
26+
parameter,
27+
OudsComponentTestSuite.theme
28+
) {
29+
30+
companion object {
31+
@JvmStatic
32+
@Parameterized.Parameters
33+
internal fun data() = OudsPreviewableComponent.SmallCardItem.Static.parameters
34+
}
35+
}
36+
37+
class StaticWithRoundedCorners : OudsComponentSnapshotTest(
38+
OudsPreviewableComponent.SmallCardItem.StaticWithRoundedCorners,
39+
parameter = null,
40+
OudsComponentTestSuite.theme
41+
)
42+
43+
@RunWith(Parameterized::class)
44+
class Navigation(parameter: Any) : OudsComponentSnapshotTest(
45+
OudsPreviewableComponent.SmallCardItem.Navigation,
46+
parameter,
47+
OudsComponentTestSuite.theme,
48+
heightDp = OudsPreviewableComponent.SmallCardItem.Navigation.PreviewHeightDp
49+
) {
50+
51+
companion object {
52+
@JvmStatic
53+
@Parameterized.Parameters
54+
internal fun data() = OudsPreviewableComponent.SmallCardItem.Navigation.parameters
55+
}
56+
}
57+
58+
class NavigationWithRoundedCorners : OudsComponentSnapshotTest(
59+
OudsPreviewableComponent.SmallCardItem.NavigationWithRoundedCorners,
60+
parameter = null,
61+
OudsComponentTestSuite.theme,
62+
heightDp = OudsPreviewableComponent.SmallCardItem.Navigation.PreviewHeightDp
63+
)
64+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Software Name: OUDS Android
3+
* SPDX-FileCopyrightText: Copyright (c) Orange SA
4+
* SPDX-License-Identifier: MIT
5+
*
6+
* This software is distributed under the MIT license,
7+
* the text of which is available at https://opensource.org/license/MIT/
8+
* or see the "LICENSE" file for more details.
9+
*
10+
* Software description: Android library of reusable graphical components
11+
*/
12+
13+
package com.orange.ouds.core.test
14+
15+
import com.orange.ouds.core.utilities.OudsPreviewableComponent
16+
import org.junit.experimental.runners.Enclosed
17+
import org.junit.runner.RunWith
18+
import org.junit.runners.Parameterized
19+
20+
@RunWith(Enclosed::class)
21+
internal class OudsSmallListItemTest {
22+
23+
@RunWith(Parameterized::class)
24+
class Static(parameter: Any) : OudsComponentSnapshotTest(
25+
OudsPreviewableComponent.SmallListItem.Static,
26+
parameter,
27+
OudsComponentTestSuite.theme
28+
) {
29+
30+
companion object {
31+
@JvmStatic
32+
@Parameterized.Parameters
33+
internal fun data() = OudsPreviewableComponent.SmallListItem.Static.parameters
34+
}
35+
}
36+
37+
@RunWith(Parameterized::class)
38+
class Navigation(parameter: Any) : OudsComponentSnapshotTest(
39+
OudsPreviewableComponent.SmallListItem.Navigation,
40+
parameter,
41+
OudsComponentTestSuite.theme,
42+
heightDp = OudsPreviewableComponent.SmallListItem.Navigation.PreviewHeightDp
43+
) {
44+
45+
companion object {
46+
@JvmStatic
47+
@Parameterized.Parameters
48+
internal fun data() = OudsPreviewableComponent.SmallListItem.Navigation.parameters
49+
}
50+
}
51+
}

core/src/main/java/com/orange/ouds/core/component/OudsCardItem.kt

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.orange.ouds.core.utilities.CheckerboardPainter
2727
import com.orange.ouds.core.utilities.OudsPreview
2828
import com.orange.ouds.core.utilities.OudsPreviewDevice
2929
import com.orange.ouds.core.utilities.OudsPreviewLightDark
30+
import com.orange.ouds.core.utilities.OudsPreviewableComponent
3031
import com.orange.ouds.core.utilities.PreviewEnumEntries
3132
import com.orange.ouds.core.utilities.getPreviewTheme
3233
import com.orange.ouds.core.utilities.mapSettings
@@ -155,11 +156,34 @@ internal fun PreviewOudsStaticCardItem(
155156
}
156157
}
157158

158-
@Preview(name = "Light", heightDp = 880, device = OudsPreviewDevice) // TODO set height in OudsPreviewableComponent
159+
@Preview(
160+
name = "Light",
161+
device = OudsPreviewDevice
162+
)
163+
@Composable
164+
@Suppress("PreviewShouldNotBeCalledRecursively")
165+
private fun PreviewOudsStaticCardItemWithRoundedCorners() {
166+
PreviewOudsStaticCardItemWithRoundedCorners(theme = getPreviewTheme())
167+
}
168+
169+
@Composable
170+
internal fun PreviewOudsStaticCardItemWithRoundedCorners(theme: OudsThemeContract) =
171+
OudsPreview(theme = theme.mapSettings { it.copy(roundedCornerCardItems = true) }) {
172+
OudsCardItem(
173+
label = "Label",
174+
decoration = OudsListItemDecoration.Outlined,
175+
description = "Description",
176+
overline = "Overline",
177+
extraLabel = "Extra label",
178+
helperText = "Helper text",
179+
)
180+
}
181+
182+
@Preview(name = "Light", heightDp = OudsPreviewableComponent.CardItem.Navigation.PreviewHeightDp, device = OudsPreviewDevice)
159183
@Preview(
160184
name = "Dark",
161185
uiMode = UI_MODE_NIGHT_YES or UI_MODE_TYPE_NORMAL,
162-
heightDp = 1000, // TODO set height in OudsPreviewableComponent
186+
heightDp = OudsPreviewableComponent.CardItem.Navigation.PreviewHeightDp,
163187
device = OudsPreviewDevice
164188
)
165189
@Composable
@@ -195,7 +219,7 @@ internal fun PreviewOudsNavigationCardItem(
195219
}
196220
}
197221

198-
@Preview(name = "Light", heightDp = 880, device = OudsPreviewDevice) // TODO set height in OudsPreviewableComponent
222+
@Preview(name = "Light", heightDp = OudsPreviewableComponent.CardItem.Navigation.PreviewHeightDp, device = OudsPreviewDevice)
199223
@Composable
200224
@Suppress("PreviewShouldNotBeCalledRecursively")
201225
private fun PreviewOudsNavigationCardItemWithRoundedCorners() {
@@ -217,35 +241,6 @@ internal fun PreviewOudsNavigationCardItemWithRoundedCorners(theme: OudsThemeCon
217241
}
218242
}
219243

220-
@Preview(
221-
name = "Dark",
222-
uiMode = UI_MODE_NIGHT_YES or UI_MODE_TYPE_NORMAL,
223-
heightDp = 880,
224-
device = OudsPreviewDevice
225-
) // TODO set height in OudsPreviewableComponent
226-
@Composable
227-
@Suppress("PreviewShouldNotBeCalledRecursively")
228-
private fun PreviewOudsStaticCardItemWithRoundedCorners() {
229-
PreviewOudsStaticCardItemWithRoundedCorners(theme = getPreviewTheme(), darkThemeEnabled = isSystemInDarkTheme())
230-
}
231-
232-
@Composable
233-
internal fun PreviewOudsStaticCardItemWithRoundedCorners(
234-
theme: OudsThemeContract,
235-
darkThemeEnabled: Boolean
236-
) = OudsPreview(theme = theme.mapSettings { it.copy(roundedCornerCardItems = true) }, darkThemeEnabled = darkThemeEnabled) {
237-
PreviewEnumEntries<OudsListItemState>(maxEnumEntriesInEachRow = 1) {
238-
OudsCardItem(
239-
label = "Label",
240-
decoration = OudsListItemDecoration.Outlined,
241-
description = "Description",
242-
overline = "Overline",
243-
extraLabel = "Extra label",
244-
helperText = "Helper text",
245-
)
246-
}
247-
}
248-
249244
internal data class OudsCardItemPreviewParameter(
250245
val label: String,
251246
val decoration: OudsListItemDecoration = OudsCardItemDefaults.Decoration,

core/src/main/java/com/orange/ouds/core/component/OudsListItem.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import com.orange.ouds.core.utilities.LayeredTintedPainter
6868
import com.orange.ouds.core.utilities.OudsPreview
6969
import com.orange.ouds.core.utilities.OudsPreviewDevice
7070
import com.orange.ouds.core.utilities.OudsPreviewLightDark
71+
import com.orange.ouds.core.utilities.OudsPreviewableComponent
7172
import com.orange.ouds.core.utilities.PreviewEnumEntries
7273
import com.orange.ouds.core.utilities.getPreviewEnumEntry
7374
import com.orange.ouds.core.utilities.getPreviewTheme
@@ -1070,11 +1071,11 @@ internal fun PreviewOudsStaticListItem(
10701071
}
10711072
}
10721073

1073-
@Preview(name = "Light", heightDp = 1000, device = OudsPreviewDevice) // TODO set height in OudsPreviewableComponent
1074+
@Preview(name = "Light", heightDp = OudsPreviewableComponent.ListItem.Navigation.PreviewHeightDp, device = OudsPreviewDevice)
10741075
@Preview(
10751076
name = "Dark",
10761077
uiMode = UI_MODE_NIGHT_YES or UI_MODE_TYPE_NORMAL,
1077-
heightDp = 1000, // TODO set height in OudsPreviewableComponent
1078+
heightDp = OudsPreviewableComponent.ListItem.Navigation.PreviewHeightDp,
10781079
device = OudsPreviewDevice
10791080
)
10801081
@Composable

0 commit comments

Comments
 (0)