-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix annotation detection in ReactiveComponent
- Loading branch information
Showing
7 changed files
with
103 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ pluginManagement { | |
|
||
rootProject.name = "void-ui" | ||
|
||
include("test-mod") | ||
//include("test-mod") |
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
19 changes: 15 additions & 4 deletions
19
src/main/kotlin/com/neptuneclient/voidui/ui/ReactiveComponent.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
18 changes: 18 additions & 0 deletions
18
src/test/kotlin/com/neptuneclient/voidui/tests/MockRenderer.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,18 @@ | ||
package com.neptuneclient.voidui.tests | ||
|
||
import com.neptuneclient.voidui.rendering.Renderer | ||
import java.awt.Color | ||
|
||
class MockRenderer : Renderer { | ||
override fun beginFrame() { | ||
println("beginFrame") | ||
} | ||
|
||
override fun endFrame() { | ||
println("endFrame") | ||
} | ||
|
||
override fun rectangle(x: Float, y: Float, width: Float, height: Float, color: Color) { | ||
println("rectangle: x=$x, y=$y, width=$width, height=$height, color=$color") | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/test/kotlin/com/neptuneclient/voidui/tests/VoidScreenTest.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,42 @@ | ||
package com.neptuneclient.voidui.tests | ||
|
||
import com.neptuneclient.voidui.VoidUI | ||
import com.neptuneclient.voidui.ui.Component | ||
import com.neptuneclient.voidui.ui.ReactiveComponent | ||
import com.neptuneclient.voidui.ui.Screen | ||
import com.neptuneclient.voidui.ui.State | ||
import org.junit.jupiter.api.Test | ||
|
||
class VoidScreenTest(void: VoidUI) : Screen(void) { | ||
override fun build(): Component { | ||
return TestComponent() | ||
} | ||
} | ||
|
||
class TestComponent : ReactiveComponent() { | ||
@State | ||
public var testState = 5 | ||
|
||
override fun build(): Component { | ||
println("Building TestComponent") | ||
return this | ||
} | ||
} | ||
|
||
object Tests { | ||
@Test | ||
fun testState() { | ||
val renderer = MockRenderer() | ||
val void = VoidUI(renderer) | ||
val screen = VoidScreenTest(void) | ||
|
||
val screen_component = screen.build() | ||
val component = screen_component.build() | ||
if (component is TestComponent) { | ||
println("TestComponent.testState: ${component.testState}") | ||
component.testState = 1 | ||
println("TestComponent.testState: ${component.testState}") | ||
} | ||
|
||
} | ||
} |