-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: nested triggers at path using incorrect method parameter
Brought up on Slack here: https://2dimensions.slack.com/archives/C029X99PETE/p1727370202337659 Explicitly setting the argument names. Added tests. Diffs= 68f58eef4 fix: nested triggers at path using incorrect method parameter (#8237) Co-authored-by: Gordon <[email protected]>
- Loading branch information
1 parent
60d9936
commit 1a214e5
Showing
4 changed files
with
85 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4566a1208a50671aede1fd1bf30a1806b757c343 | ||
68f58eef4ef521e93a5ada5cb3bf4fbfc7c7687d |
75 changes: 75 additions & 0 deletions
75
kotlin/src/androidTest/java/app/rive/runtime/kotlin/core/RiveNestedInputsTest.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,75 @@ | ||
package app.rive.runtime.kotlin.core | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.internal.runner.junit4.statement.UiThreadStatement | ||
import app.rive.runtime.kotlin.core.errors.StateMachineInputException | ||
import app.rive.runtime.kotlin.test.R | ||
import org.junit.Assert.assertThrows | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class RiveNestedInputsTest { | ||
private val testUtils = TestUtils() | ||
private val appContext = testUtils.context | ||
private lateinit var view: TestUtils.MockRiveAnimationView | ||
|
||
|
||
@Before | ||
fun init() { | ||
view = TestUtils.MockRiveAnimationView(appContext) | ||
} | ||
|
||
@Test | ||
fun can_set_inputs_at_path_no_errors() { | ||
UiThreadStatement.runOnUiThread { | ||
view.setRiveResource(R.raw.nested_inputs_test, artboardName = "Artboard", stateMachineName = "State Machine 1") | ||
view.play() | ||
view.setBooleanStateAtPath("bool", true, "nested") | ||
view.setNumberStateAtPath("number", 1f, "nested") | ||
view.fireStateAtPath("trigger", "nested") | ||
} | ||
} | ||
|
||
@Test | ||
fun set_incorrect_name_inputs_at_path_throws() { | ||
UiThreadStatement.runOnUiThread { | ||
view.setRiveResource(R.raw.nested_inputs_test, artboardName = "Artboard", stateMachineName = "State Machine 1") | ||
view.play() | ||
assertThrows(StateMachineInputException::class.java) { | ||
view.setBooleanStateAtPath("wrongname", true, "nested") | ||
view.artboardRenderer?.advance(0.16f) | ||
} | ||
assertThrows(StateMachineInputException::class.java) { | ||
view.setNumberStateAtPath("wrongname", 1f, "nested") | ||
view.artboardRenderer?.advance(0.16f) | ||
} | ||
assertThrows(StateMachineInputException::class.java) { | ||
view.fireStateAtPath("wrongname", "nested") | ||
view.artboardRenderer?.advance(0.16f) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun set_incorrect_path_inputs_at_path_throws() { | ||
UiThreadStatement.runOnUiThread { | ||
view.setRiveResource(R.raw.nested_inputs_test, artboardName = "Artboard", stateMachineName = "State Machine 1") | ||
view.play() | ||
assertThrows(StateMachineInputException::class.java) { | ||
view.setBooleanStateAtPath("bool", true, "wrongPath") | ||
view.artboardRenderer?.advance(0.16f) | ||
} | ||
assertThrows(StateMachineInputException::class.java) { | ||
view.setNumberStateAtPath("number", 1f, "wrongPath") | ||
view.artboardRenderer?.advance(0.16f) | ||
} | ||
assertThrows(StateMachineInputException::class.java) { | ||
view.fireStateAtPath("trigger", "wrongPath") | ||
view.artboardRenderer?.advance(0.16f) | ||
} | ||
} | ||
} | ||
|
||
} |
Binary file not shown.
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