|
1 |
| -package com.x8bit.bitwarden.data.platform.base.util |
| 1 | +package com.bitwarden.ui.platform.base.util |
2 | 2 |
|
| 3 | +import androidx.compose.runtime.Composable |
3 | 4 | import androidx.compose.ui.graphics.Color
|
| 5 | +import com.bitwarden.ui.platform.base.BaseComposeTest |
4 | 6 | import com.bitwarden.ui.platform.feature.settings.appearance.model.AppTheme
|
5 | 7 | import com.bitwarden.ui.platform.theme.BitwardenTheme
|
6 |
| -import com.x8bit.bitwarden.ui.platform.base.BitwardenComposeTest |
7 |
| -import com.x8bit.bitwarden.ui.platform.base.util.isLightOverlayRequired |
8 |
| -import com.x8bit.bitwarden.ui.platform.base.util.toSafeOverlayColor |
9 |
| -import org.junit.Assert.assertEquals |
10 |
| -import org.junit.Assert.assertFalse |
11 |
| -import org.junit.Assert.assertTrue |
| 8 | +import org.junit.Assert |
12 | 9 | import org.junit.Test
|
13 | 10 |
|
14 |
| -class ColorExtensionsTest : BitwardenComposeTest() { |
| 11 | +class ColorExtensionsTest : BaseComposeTest() { |
| 12 | + |
15 | 13 | @Suppress("MaxLineLength")
|
16 | 14 | @Test
|
17 | 15 | fun `isLightOverlayRequired for a color with luminance below the light threshold should return true`() {
|
18 |
| - assertTrue(Color.Blue.isLightOverlayRequired) |
| 16 | + Assert.assertTrue(Color.Companion.Blue.isLightOverlayRequired) |
19 | 17 | }
|
20 | 18 |
|
21 | 19 | @Suppress("MaxLineLength")
|
22 | 20 | @Test
|
23 | 21 | fun `isLightOverlayRequired for a color with luminance above the light threshold should return false`() {
|
24 |
| - assertFalse(Color.Yellow.isLightOverlayRequired) |
| 22 | + Assert.assertFalse(Color.Companion.Yellow.isLightOverlayRequired) |
25 | 23 | }
|
26 | 24 |
|
27 | 25 | @Test
|
28 | 26 | fun `toSafeOverlayColor for a dark color in light mode should use the surface color`() =
|
29 | 27 | setContent(theme = AppTheme.LIGHT) {
|
30 |
| - assertEquals( |
| 28 | + Assert.assertEquals( |
31 | 29 | BitwardenTheme.colorScheme.background.primary,
|
32 |
| - Color.Blue.toSafeOverlayColor(), |
| 30 | + Color.Companion.Blue.toSafeOverlayColor(), |
33 | 31 | )
|
34 | 32 | }
|
35 | 33 |
|
36 | 34 | @Test
|
37 | 35 | fun `toSafeOverlayColor for a dark color in dark mode should use the onSurface color`() =
|
38 | 36 | setContent(theme = AppTheme.DARK) {
|
39 |
| - assertEquals( |
| 37 | + Assert.assertEquals( |
40 | 38 | BitwardenTheme.colorScheme.text.primary,
|
41 |
| - Color.Blue.toSafeOverlayColor(), |
| 39 | + Color.Companion.Blue.toSafeOverlayColor(), |
42 | 40 | )
|
43 | 41 | }
|
44 | 42 |
|
45 | 43 | @Test
|
46 | 44 | fun `toSafeOverlayColor for a light color in light mode should use the onSurface color`() =
|
47 | 45 | setContent(theme = AppTheme.LIGHT) {
|
48 |
| - assertEquals( |
| 46 | + Assert.assertEquals( |
49 | 47 | BitwardenTheme.colorScheme.text.primary,
|
50 |
| - Color.Yellow.toSafeOverlayColor(), |
| 48 | + Color.Companion.Yellow.toSafeOverlayColor(), |
51 | 49 | )
|
52 | 50 | }
|
53 | 51 |
|
54 | 52 | @Test
|
55 | 53 | fun `toSafeOverlayColor for a light color in dark mode should use the surface color`() =
|
56 | 54 | setContent(theme = AppTheme.DARK) {
|
57 |
| - assertEquals( |
| 55 | + Assert.assertEquals( |
58 | 56 | BitwardenTheme.colorScheme.background.primary,
|
59 |
| - Color.Yellow.toSafeOverlayColor(), |
| 57 | + Color.Companion.Yellow.toSafeOverlayColor(), |
60 | 58 | )
|
61 | 59 | }
|
| 60 | + |
| 61 | + @Suppress("LongParameterList") |
| 62 | + fun setContent( |
| 63 | + theme: AppTheme = AppTheme.DEFAULT, |
| 64 | + test: @Composable () -> Unit, |
| 65 | + ) { |
| 66 | + setTestContent { |
| 67 | + BitwardenTheme( |
| 68 | + theme = theme, |
| 69 | + content = test, |
| 70 | + ) |
| 71 | + } |
| 72 | + } |
62 | 73 | }
|
0 commit comments