Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Remove tests which panic in signals #519

Merged
merged 1 commit into from Aug 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 2 additions & 33 deletions src/subclass/object.rs
Expand Up @@ -666,18 +666,8 @@ mod test {
assert_eq!(value.get::<String>(), Ok(Some("return value".to_string())));
}

#[cfg(not(all(windows, target_pointer_width = "32")))] // Windows 32bits CI fails on this test
#[test]
#[should_panic(expected = "Signal required return value of type gchararray but got gboolean")]
fn test_signal_return_wrong_type() {
let obj = Object::new(SimpleObject::get_type(), &[]).unwrap();

// Returning a `bool` when a `String` was expected
obj.connect("create-string", false, move |_args| Some(true.to_value()))
.unwrap();

let _res = obj.emit("create-string", &[]);
}
// Note: can't test type mismatch in signals since panics accross FFI boundaries
// are UB. See https://github.com/gtk-rs/glib/issues/518

#[test]
fn test_signal_return_expected_object_type() {
Expand All @@ -695,25 +685,4 @@ mod test {
let value = obj.emit("create-child-object", &[]).unwrap().unwrap();
assert!(value.type_().is_a(&ChildObject::static_type()));
}

#[cfg(not(all(windows, target_pointer_width = "32")))] // Windows 32bits CI fails on this test
#[test]
#[should_panic(
expected = "Signal required return value of type ChildObject but got GObject (actual SimpleObject)"
)]
fn test_signal_return_wrong_object_type() {
let obj = Object::new(SimpleObject::get_type(), &[]).unwrap();

// Returning a `SimpleObject` when a `ChildObject` was expected
obj.connect("create-child-object", false, move |_args| {
Some(
Object::new(SimpleObject::get_type(), &[])
.unwrap()
.to_value(),
)
})
.unwrap();

let _res = obj.emit("create-child-object", &[]);
}
}