-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for painter hints
- Loading branch information
Showing
29 changed files
with
534 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
core/src/main/kotlin/org/jetbrains/jewel/painter/hints/HiDpi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.jetbrains.jewel.painter.hints | ||
|
||
import androidx.compose.runtime.Immutable | ||
import org.jetbrains.jewel.painter.BitmapPainterHint | ||
import org.jetbrains.jewel.painter.PainterHint | ||
import org.jetbrains.jewel.painter.PainterSuffixHint | ||
|
||
@Immutable | ||
private object HiDpiImpl : PainterSuffixHint(), BitmapPainterHint { | ||
|
||
override fun suffix(): String = "@2x" | ||
|
||
override fun toString(): String = "HiDpi" | ||
} | ||
|
||
fun HiDpi(isHiDpi: Boolean): PainterHint = if (isHiDpi) { | ||
HiDpiImpl | ||
} else { | ||
PainterHint.None | ||
} | ||
|
||
fun HiDpi(density: androidx.compose.ui.unit.Density): PainterHint = HiDpi(density.density > 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
core/src/test/kotlin/org/jetbrains/jewel/BasicJewelUiTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.jetbrains.jewel | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.test.junit4.ComposeContentTestRule | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.Before | ||
import org.junit.Rule | ||
|
||
open class BasicJewelUiTest { | ||
|
||
@get:Rule | ||
val composeRule = createComposeRule() | ||
|
||
@Suppress("ImplicitUnitReturnType") | ||
protected fun runComposeTest( | ||
composable: @Composable () -> Unit, | ||
block: suspend ComposeContentTestRule.() -> Unit, | ||
) = runBlocking { | ||
composeRule.setContent(composable) | ||
composeRule.block() | ||
} | ||
|
||
@Before | ||
fun setUpProperties() { | ||
System.setProperty("org.jetbrains.jewel.debug", "true") | ||
} | ||
} |
Oops, something went wrong.