@@ -123,22 +123,30 @@ impl NodeVirtual for ReturnVirtualTest {
123
123
124
124
// ----------------------------------------------------------------------------------------------------------------------------------------------
125
125
126
+ #[ derive( Eq , PartialEq , Debug ) ]
127
+ enum ReceivedEvent {
128
+ Notification ( NodeNotification ) ,
129
+ Ready ,
130
+ }
131
+
126
132
#[ derive( GodotClass , Debug ) ]
127
133
#[ class( base=Node , init) ]
128
134
struct NotificationTest {
129
135
#[ base]
130
136
base : Base < Node > ,
131
137
132
- sequence : Vec < NodeNotification > ,
138
+ sequence : Vec < ReceivedEvent > ,
133
139
}
134
140
135
141
#[ godot_api]
136
142
impl NodeVirtual for NotificationTest {
137
143
fn on_notification ( & mut self , what : NodeNotification ) {
138
- self . sequence . push ( what) ;
144
+ self . sequence . push ( ReceivedEvent :: Notification ( what) ) ;
139
145
}
140
146
141
- fn ready ( & mut self ) { }
147
+ fn ready ( & mut self ) {
148
+ self . sequence . push ( ReceivedEvent :: Ready ) ;
149
+ }
142
150
}
143
151
144
152
// ----------------------------------------------------------------------------------------------------------------------------------------------
@@ -277,23 +285,24 @@ fn test_virtual_method_with_return() {
277
285
obj. free ( ) ;
278
286
}
279
287
280
- #[ itest]
288
+ #[ itest( focus ) ]
281
289
fn test_notifications ( ) {
282
290
let obj = Gd :: < NotificationTest > :: new_default ( ) ;
283
-
284
291
let mut node = obj. share ( ) . upcast :: < Node > ( ) ;
285
292
node. issue_notification ( NodeNotification :: Unpaused ) ;
286
293
node. issue_notification ( NodeNotification :: EditorPostSave ) ;
287
- node. issue_notification ( NodeNotification :: WmSizeChanged ) ;
294
+ node. issue_notification ( NodeNotification :: Ready ) ;
295
+ node. issue_notification_reversed ( NodeNotification :: WmSizeChanged ) ;
288
296
289
297
assert_eq ! (
290
298
obj. bind( ) . sequence,
291
299
vec![
292
- Node :: NOTIFICATION_UNPAUSED . into( ) ,
293
- Node :: NOTIFICATION_EDITOR_POST_SAVE . into( ) ,
294
- Node :: NOTIFICATION_WM_SIZE_CHANGED . into( ) ,
300
+ ReceivedEvent :: Notification ( NodeNotification :: Unpaused ) ,
301
+ ReceivedEvent :: Notification ( NodeNotification :: EditorPostSave ) ,
302
+ ReceivedEvent :: Ready ,
303
+ ReceivedEvent :: Notification ( NodeNotification :: Ready ) ,
304
+ ReceivedEvent :: Notification ( NodeNotification :: WmSizeChanged ) ,
295
305
]
296
306
) ;
297
-
298
307
obj. free ( ) ;
299
308
}
0 commit comments