Rework and fix for orx-parameter/orx-gui ButtonParameter (now ActionParameter)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import org.amshove.kluent.`should be equal to`
|
||||
import org.amshove.kluent.shouldBeInRange
|
||||
import org.amshove.kluent.*
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.parameters.*
|
||||
import org.spekframework.spek2.Spek
|
||||
import org.spekframework.spek2.style.specification.describe
|
||||
import java.lang.IllegalArgumentException
|
||||
|
||||
val a = object {
|
||||
@DoubleParameter("a double scalar", 0.0, 1.0, order = 0)
|
||||
@@ -15,8 +15,10 @@ val a = object {
|
||||
@BooleanParameter("a boolean parameter", order = 2)
|
||||
var b = false
|
||||
|
||||
@ButtonParameter("a button parameter", order = 3)
|
||||
var f = {}
|
||||
@ActionParameter("an action parameter", order = 3)
|
||||
fun a() {
|
||||
error("this is to test if this function can be called")
|
||||
}
|
||||
|
||||
@TextParameter("a text parameter", order = 4)
|
||||
var t = "test"
|
||||
@@ -32,7 +34,7 @@ object TestAnnotations : Spek({
|
||||
val list = a.listParameters()
|
||||
list.size `should be equal to` 6
|
||||
|
||||
list[0].property.name `should be equal to` "d"
|
||||
list[0].property?.name `should be equal to` "d"
|
||||
list[0].parameterType `should be equal to` ParameterType.Double
|
||||
list[0].label `should be equal to` "a double scalar"
|
||||
list[0].doubleRange?.let {
|
||||
@@ -41,29 +43,41 @@ object TestAnnotations : Spek({
|
||||
}
|
||||
list[0].precision `should be equal to` 3
|
||||
|
||||
list[1].property.name `should be equal to` "i"
|
||||
list[1].property?.name `should be equal to` "i"
|
||||
list[1].parameterType `should be equal to` ParameterType.Int
|
||||
list[1].label `should be equal to` "an integer scalar"
|
||||
list[1].intRange?.let {
|
||||
it.start `should be equal to` 1
|
||||
it.endInclusive `should be equal to` 100
|
||||
it.first `should be equal to` 1
|
||||
it.last `should be equal to` 100
|
||||
}
|
||||
|
||||
list[2].property.name `should be equal to` "b"
|
||||
list[2].property?.name `should be equal to` "b"
|
||||
list[2].parameterType `should be equal to` ParameterType.Boolean
|
||||
list[2].label `should be equal to` "a boolean parameter"
|
||||
list[2].precision `should be equal to` null
|
||||
|
||||
list[3].parameterType `should be equal to` ParameterType.Button
|
||||
list[3].property.name `should be equal to` "f"
|
||||
list[3].label `should be equal to` "a button parameter"
|
||||
list[3].parameterType `should be equal to` ParameterType.Action
|
||||
list[3].property `should be equal to` null
|
||||
list[3].label `should be equal to` "an action parameter"
|
||||
|
||||
/* test if we can call the annotated function, this is performed by raising an expected exception in the
|
||||
function in the annotated function.
|
||||
*/
|
||||
invoking {
|
||||
try {
|
||||
list[3].function?.call(a)
|
||||
} catch(e: java.lang.reflect.InvocationTargetException) {
|
||||
/* this unpacks the exception that is wrapped in the ITExc */
|
||||
throw(e.targetException)
|
||||
}
|
||||
} `should throw` IllegalStateException::class withMessage "this is to test if this function can be called"
|
||||
|
||||
list[4].parameterType `should be equal to` ParameterType.Text
|
||||
list[4].property.name `should be equal to` "t"
|
||||
list[4].property?.name `should be equal to` "t"
|
||||
list[4].label `should be equal to` "a text parameter"
|
||||
|
||||
list[5].parameterType `should be equal to` ParameterType.Color
|
||||
list[5].property.name `should be equal to` "c"
|
||||
list[5].property?.name `should be equal to` "c"
|
||||
list[5].label `should be equal to` "a color parameter"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user