@@ -465,72 +465,75 @@ TEST_CASE("[Object] Signals") {
465465 }
466466}
467467
468- class NotificationObject1 : public Object {
469- GDCLASS (NotificationObject1 , Object);
468+ class NotificationObjectSuperclass : public Object {
469+ GDCLASS (NotificationObjectSuperclass , Object);
470470
471471protected:
472472 void _notification (int p_what) {
473- switch (p_what) {
474- case 12345 : {
475- order_internal1 = order_global++;
476- } break ;
477- }
473+ order_superclass = ++order_global;
478474 }
479475
480476public:
481- static int order_global;
482- int order_internal1 = -1 ;
483-
484- void reset_order () {
485- order_internal1 = -1 ;
486- order_global = 1 ;
487- }
477+ static inline int order_global = 0 ;
478+ int order_superclass = -1 ;
488479};
489480
490- int NotificationObject1::order_global = 1 ;
491-
492- class NotificationObject2 : public NotificationObject1 {
493- GDCLASS (NotificationObject2, NotificationObject1);
481+ class NotificationObjectSubclass : public NotificationObjectSuperclass {
482+ GDCLASS (NotificationObjectSubclass, NotificationObjectSuperclass);
494483
495484protected:
496485 void _notification (int p_what) {
497- switch (p_what) {
498- case 12345 : {
499- order_internal2 = order_global++;
500- } break ;
501- }
486+ order_subclass = ++order_global;
502487 }
503488
504489public:
505- int order_internal2 = -1 ;
506- void reset_order () {
507- NotificationObject1::reset_order ();
508- order_internal2 = -1 ;
490+ int order_subclass = -1 ;
491+ };
492+
493+ class NotificationScriptInstance : public _MockScriptInstance {
494+ void notification (int p_notification, bool p_reversed) override {
495+ order_script = ++NotificationObjectSuperclass::order_global;
509496 }
497+
498+ public:
499+ int order_script = -1 ;
510500};
511501
512502TEST_CASE (" [Object] Notification order" ) { // GH-52325
513- NotificationObject2 *test_notification_object = memnew (NotificationObject2 );
503+ NotificationObjectSubclass *object = memnew (NotificationObjectSubclass );
514504
515- SUBCASE ( " regular order " ) {
516- test_notification_object-> notification ( 12345 , false );
505+ NotificationScriptInstance *script = memnew (NotificationScriptInstance);
506+ object-> set_script_instance (script );
517507
518- CHECK_EQ (test_notification_object->order_internal1 , 1 );
519- CHECK_EQ (test_notification_object->order_internal2 , 2 );
508+ SUBCASE (" regular order" ) {
509+ NotificationObjectSubclass::order_global = 0 ;
510+ object->order_superclass = -1 ;
511+ object->order_subclass = -1 ;
512+ script->order_script = -1 ;
513+ object->notification (12345 , false );
520514
521- test_notification_object->reset_order ();
515+ CHECK_EQ (object->order_superclass , 1 );
516+ CHECK_EQ (object->order_subclass , 2 );
517+ // TODO If an extension is attached, it should come here.
518+ CHECK_EQ (script->order_script , 3 );
519+ CHECK_EQ (NotificationObjectSubclass::order_global, 3 );
522520 }
523521
524522 SUBCASE (" reverse order" ) {
525- test_notification_object->notification (12345 , true );
526-
527- CHECK_EQ (test_notification_object->order_internal1 , 2 );
528- CHECK_EQ (test_notification_object->order_internal2 , 1 );
523+ NotificationObjectSubclass::order_global = 0 ;
524+ object->order_superclass = -1 ;
525+ object->order_subclass = -1 ;
526+ script->order_script = -1 ;
527+ object->notification (12345 , true );
529528
530- test_notification_object->reset_order ();
529+ CHECK_EQ (script->order_script , 1 );
530+ // TODO If an extension is attached, it should come here.
531+ CHECK_EQ (object->order_subclass , 2 );
532+ CHECK_EQ (object->order_superclass , 3 );
533+ CHECK_EQ (NotificationObjectSubclass::order_global, 3 );
531534 }
532535
533- memdelete (test_notification_object );
536+ memdelete (object );
534537}
535538
536539TEST_CASE (" [Object] Destruction at the end of the call chain is safe" ) {
0 commit comments