-
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.
- Loading branch information
1 parent
0bc7bd0
commit b4b1a63
Showing
9 changed files
with
82 additions
and
11 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
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 help | ||
|
||
import io.kotest.matchers.shouldBe | ||
import javax.swing.JTextPane | ||
import main.kotlin.testCore.AbstractTest | ||
import org.junit.jupiter.api.Test | ||
import utils.getAllChildComponentsForType | ||
|
||
abstract class AbstractHelpPanelTest<T : HelpPanel> : AbstractTest() { | ||
abstract fun factory(): T | ||
|
||
@Test | ||
fun `All text panes should be read-only`() { | ||
val pane = factory() | ||
val textPanes = pane.getAllChildComponentsForType<JTextPane>() | ||
textPanes.forEach { it.isEditable shouldBe false } | ||
} | ||
} |
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,47 @@ | ||
package help | ||
|
||
import io.kotest.matchers.shouldBe | ||
import java.awt.Color | ||
import java.awt.Font | ||
import javax.swing.JTextPane | ||
import main.kotlin.testCore.AbstractTest | ||
import org.junit.jupiter.api.Test | ||
import util.EntropyColour | ||
|
||
class HelpPanelTest : AbstractTest() { | ||
@Test | ||
fun `should report whether text is contained`() { | ||
val panel = FakeHelpPanel() | ||
|
||
panel.contains("first") shouldBe true | ||
panel.contains("second") shouldBe true | ||
panel.contains("third") shouldBe false | ||
} | ||
} | ||
|
||
class FakeHelpPanel : HelpPanel() { | ||
override val nodeName = "Fake Panel" | ||
|
||
private val title = JTextPane() | ||
private val paneOne = JTextPane() | ||
private val paneTwo = JTextPane() | ||
|
||
init { | ||
background = Color.WHITE | ||
layout = null | ||
paneOne.font = Font("SansSerif", Font.PLAIN, 14) | ||
paneOne.contentType = "text/html" | ||
paneOne.text = "<html>First panel.</html>" | ||
paneOne.setBounds(21, 54, 429, 220) | ||
add(paneOne) | ||
paneTwo.text = "<html>Second panel.</html>" | ||
add(paneTwo) | ||
title.foreground = EntropyColour.COLOUR_HELP_TITLE | ||
title.font = Font("Tahoma", Font.BOLD, 18) | ||
title.text = "Fake Panel" | ||
title.setBounds(21, 25, 159, 30) | ||
add(title) | ||
|
||
finaliseComponents() | ||
} | ||
} |
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,5 @@ | ||
package help | ||
|
||
class RulesIllegalTest : AbstractHelpPanelTest<RulesIllegal>() { | ||
override fun factory() = RulesIllegal() | ||
} |
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,5 @@ | ||
package help | ||
|
||
class RulesVectropyBiddingTest : AbstractHelpPanelTest<RulesVectropyBidding>() { | ||
override fun factory() = RulesVectropyBidding() | ||
} |
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,5 @@ | ||
package help | ||
|
||
class RulesVectropyChallengingTest : AbstractHelpPanelTest<RulesVectropyChallenging>() { | ||
override fun factory() = RulesVectropyChallenging() | ||
} |