Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Blasius committed May 15, 2024
1 parent b5c80a3 commit 801a18f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/compiler/widgets/common/combobox-base.slint
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export component ComboBoxBase {
return;
}
root.current-index = index;
root.update-current-value();

if root.current-value != root.model[root.current-index] {
root.update-current-value();
}

root.selected(root.current-value);
}

Expand Down
3 changes: 3 additions & 0 deletions tests/cases/widgets/combobox.slint
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use std::rc::Rc;
use slint::platform::Key;
use slint::SharedString;
use slint::VecModel;
use i_slint_backend_testing::mock_elapsed_time;
let instance = TestCase::new().unwrap();
Expand Down Expand Up @@ -91,10 +92,12 @@ instance.set_output(Default::default());
// Set current-index to -1
instance.set_current_index(-1);
mock_elapsed_time(500);
assert_eq!(instance.get_current_value(), &SharedString::from(""));
// Replace model
instance.set_model(Rc::new(VecModel::from_slice(&[SharedString::from("A"), SharedString::from("B")])).into());
mock_elapsed_time(500);
assert_eq!(instance.get_current_index(), 0);
assert_eq!(instance.get_current_value(), &SharedString::from("A"));
Expand Down

0 comments on commit 801a18f

Please sign in to comment.