@@ -464,72 +464,75 @@ TEST_CASE("[Object] Signals") {
464464 }
465465}
466466
467- class NotificationObject1 : public Object {
468- GDCLASS (NotificationObject1 , Object);
467+ class NotificationObjectSuperclass : public Object {
468+ GDCLASS (NotificationObjectSuperclass , Object);
469469
470470protected:
471471 void _notification (int p_what) {
472- switch (p_what) {
473- case 12345 : {
474- order_internal1 = order_global++;
475- } break ;
476- }
472+ order_superclass = ++order_global;
477473 }
478474
479475public:
480- static int order_global;
481- int order_internal1 = -1 ;
482-
483- void reset_order () {
484- order_internal1 = -1 ;
485- order_global = 1 ;
486- }
476+ static inline int order_global = 0 ;
477+ int order_superclass = -1 ;
487478};
488479
489- int NotificationObject1::order_global = 1 ;
490-
491- class NotificationObject2 : public NotificationObject1 {
492- GDCLASS (NotificationObject2, NotificationObject1);
480+ class NotificationObjectSubclass : public NotificationObjectSuperclass {
481+ GDCLASS (NotificationObjectSubclass, NotificationObjectSuperclass);
493482
494483protected:
495484 void _notification (int p_what) {
496- switch (p_what) {
497- case 12345 : {
498- order_internal2 = order_global++;
499- } break ;
500- }
485+ order_subclass = ++order_global;
501486 }
502487
503488public:
504- int order_internal2 = -1 ;
505- void reset_order () {
506- NotificationObject1::reset_order ();
507- order_internal2 = -1 ;
489+ int order_subclass = -1 ;
490+ };
491+
492+ class NotificationScriptInstance : public _MockScriptInstance {
493+ void notification (int p_notification, bool p_reversed) override {
494+ order_script = ++NotificationObjectSuperclass::order_global;
508495 }
496+
497+ public:
498+ int order_script = -1 ;
509499};
510500
511501TEST_CASE (" [Object] Notification order" ) { // GH-52325
512- NotificationObject2 *test_notification_object = memnew (NotificationObject2 );
502+ NotificationObjectSubclass *object = memnew (NotificationObjectSubclass );
513503
514- SUBCASE ( " regular order " ) {
515- test_notification_object-> notification ( 12345 , false );
504+ NotificationScriptInstance *script = memnew (NotificationScriptInstance);
505+ object-> set_script_instance (script );
516506
517- CHECK_EQ (test_notification_object->order_internal1 , 1 );
518- CHECK_EQ (test_notification_object->order_internal2 , 2 );
507+ SUBCASE (" regular order" ) {
508+ NotificationObjectSubclass::order_global = 0 ;
509+ object->order_superclass = -1 ;
510+ object->order_subclass = -1 ;
511+ script->order_script = -1 ;
512+ object->notification (12345 , false );
519513
520- test_notification_object->reset_order ();
514+ CHECK_EQ (object->order_superclass , 1 );
515+ CHECK_EQ (object->order_subclass , 2 );
516+ // TODO If an extension is attached, it should come here.
517+ CHECK_EQ (script->order_script , 3 );
518+ CHECK_EQ (NotificationObjectSubclass::order_global, 3 );
521519 }
522520
523521 SUBCASE (" reverse order" ) {
524- test_notification_object->notification (12345 , true );
525-
526- CHECK_EQ (test_notification_object->order_internal1 , 2 );
527- CHECK_EQ (test_notification_object->order_internal2 , 1 );
522+ NotificationObjectSubclass::order_global = 0 ;
523+ object->order_superclass = -1 ;
524+ object->order_subclass = -1 ;
525+ script->order_script = -1 ;
526+ object->notification (12345 , true );
528527
529- test_notification_object->reset_order ();
528+ CHECK_EQ (script->order_script , 1 );
529+ // TODO If an extension is attached, it should come here.
530+ CHECK_EQ (object->order_subclass , 2 );
531+ CHECK_EQ (object->order_superclass , 3 );
532+ CHECK_EQ (NotificationObjectSubclass::order_global, 3 );
530533 }
531534
532- memdelete (test_notification_object );
535+ memdelete (object );
533536}
534537
535538TEST_CASE (" [Object] Destruction at the end of the call chain is safe" ) {
0 commit comments