@@ -295,6 +295,10 @@ mod test {
295
295
296
296
glib_object_subclass ! ( ) ;
297
297
298
+ fn type_init ( type_ : & mut subclass:: InitializingType < Self > ) {
299
+ type_. add_interface :: < DummyInterface > ( ) ;
300
+ }
301
+
298
302
fn class_init ( klass : & mut subclass:: simple:: ClassStruct < Self > ) {
299
303
klass. install_properties ( & PROPERTIES ) ;
300
304
@@ -363,11 +367,42 @@ mod test {
363
367
}
364
368
}
365
369
370
+ #[ repr( C ) ]
371
+ pub struct DummyInterface {
372
+ parent : gobject_ffi:: GTypeInterface ,
373
+ }
374
+
375
+ impl ObjectInterface for DummyInterface {
376
+ const NAME : & ' static str = "DummyInterface" ;
377
+
378
+ glib_object_interface ! ( ) ;
379
+
380
+ fn type_init ( type_ : & mut subclass:: InitializingType < Self > ) {
381
+ type_. add_prerequisite :: < Object > ( ) ;
382
+ }
383
+ }
384
+
385
+ // Usually this would be implemented on a Rust wrapper type defined
386
+ // with glib_wrapper!() but for the test the following is sufficient
387
+ impl StaticType for DummyInterface {
388
+ fn static_type ( ) -> Type {
389
+ DummyInterface :: get_type ( )
390
+ }
391
+ }
392
+
393
+ // Usually this would be implemented on a Rust wrapper type defined
394
+ // with glib_wrapper!() but for the test the following is sufficient
395
+ unsafe impl < T : ObjectSubclass > IsImplementable < T > for DummyInterface {
396
+ unsafe extern "C" fn interface_init ( _iface : ffi:: gpointer , _iface_data : ffi:: gpointer ) { }
397
+ }
398
+
366
399
#[ test]
367
400
fn test_create ( ) {
368
401
let type_ = SimpleObject :: get_type ( ) ;
369
402
let obj = Object :: new ( type_, & [ ] ) . unwrap ( ) ;
370
403
404
+ assert ! ( obj. get_type( ) . is_a( & DummyInterface :: static_type( ) ) ) ;
405
+
371
406
assert_eq ! (
372
407
obj. get_property( "constructed" ) . unwrap( ) . get:: <bool >( ) ,
373
408
Some ( true )
0 commit comments