git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commit12a5349215c990ced3bd1b7f9049efc2c01e2400
parent3fb31b4b8a
authorLucas Galante <[email protected]>
date2026-06-29 20:34
Add unit test for spinbox click event handling

 src/widget/input/spinbox.rs | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/widget/input/spinbox.rs b/src/widget/input/spinbox.rs
index 107d90c..0c4e30e 100644
--- a/src/widget/input/spinbox.rs
+++ b/src/widget/input/spinbox.rs
@@ -456,3 +456,26 @@ impl Control for Spinbox {}
 unsafe impl Send for Spinbox {}
 unsafe impl Sync for Spinbox {}
 
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn test_spinbox_click() {
+        let mut ui_context = UiContext::new();
+        let mut sb = Spinbox::new(0, -100, 100, 1);
+        sb.set_rect(10.0, 20.0, 100.0, 26.0);
+
+        // Click on the decrease button (-)
+        let handled = sb.mouse_input(
+            MouseButton::Left,
+            ElementState::Pressed,
+            75.0,
+            33.0,
+            &mut ui_context
+        );
+        assert!(handled);
+        assert_eq!(sb.value, -1);
+    }
+}
+