summaryrefslogtreecommitdiffstats
path: root/tests/core/object/test_object.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/core/object/test_object.h')
-rw-r--r--tests/core/object/test_object.h70
1 files changed, 69 insertions, 1 deletions
diff --git a/tests/core/object/test_object.h b/tests/core/object/test_object.h
index a3d6b38ca4..e5d91db650 100644
--- a/tests/core/object/test_object.h
+++ b/tests/core/object/test_object.h
@@ -98,7 +98,7 @@ public:
Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override {
return Variant();
}
- void notification(int p_notification) override {
+ void notification(int p_notification, bool p_reversed = false) override {
}
Ref<Script> get_script() const override {
return Ref<Script>();
@@ -426,6 +426,74 @@ TEST_CASE("[Object] Signals") {
}
}
+class NotificationObject1 : public Object {
+ GDCLASS(NotificationObject1, Object);
+
+protected:
+ void _notification(int p_what) {
+ switch (p_what) {
+ case 12345: {
+ order_internal1 = order_global++;
+ } break;
+ }
+ }
+
+public:
+ static int order_global;
+ int order_internal1 = -1;
+
+ void reset_order() {
+ order_internal1 = -1;
+ order_global = 1;
+ }
+};
+
+int NotificationObject1::order_global = 1;
+
+class NotificationObject2 : public NotificationObject1 {
+ GDCLASS(NotificationObject2, NotificationObject1);
+
+protected:
+ void _notification(int p_what) {
+ switch (p_what) {
+ case 12345: {
+ order_internal2 = order_global++;
+ } break;
+ }
+ }
+
+public:
+ int order_internal2 = -1;
+ void reset_order() {
+ NotificationObject1::reset_order();
+ order_internal2 = -1;
+ }
+};
+
+TEST_CASE("[Object] Notification order") { // GH-52325
+ NotificationObject2 *test_notification_object = memnew(NotificationObject2);
+
+ SUBCASE("regular order") {
+ test_notification_object->notification(12345, false);
+
+ CHECK_EQ(test_notification_object->order_internal1, 1);
+ CHECK_EQ(test_notification_object->order_internal2, 2);
+
+ test_notification_object->reset_order();
+ }
+
+ SUBCASE("reverse order") {
+ test_notification_object->notification(12345, true);
+
+ CHECK_EQ(test_notification_object->order_internal1, 2);
+ CHECK_EQ(test_notification_object->order_internal2, 1);
+
+ test_notification_object->reset_order();
+ }
+
+ memdelete(test_notification_object);
+}
+
} // namespace TestObject
#endif // TEST_OBJECT_H