diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-05-23 12:37:01 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-05-23 12:37:01 +0200 |
| commit | 7572108d6774bd3b501e1dd3fab2a014ed164fcf (patch) | |
| tree | 532c8948d89db0cd730be45112e8022af41df156 /lib | |
| parent | d1d171775f768be1dcdee194be5134f334c63347 (diff) | |
| download | turns-7572108d6774bd3b501e1dd3fab2a014ed164fcf.tar.xz turns-7572108d6774bd3b501e1dd3fab2a014ed164fcf.zip | |
lib: add participant-count property to TurnOrder
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/src/turns-turn-order.c | 13 | ||||
| -rw-r--r-- | lib/src/turnsmm/turn-order.cpp | 4 | ||||
| -rw-r--r-- | lib/tests/turns-turn-order.cpp | 27 | ||||
| -rw-r--r-- | lib/tests/turnsmm/turn-order.cpp | 7 |
4 files changed, 46 insertions, 5 deletions
diff --git a/lib/src/turns-turn-order.c b/lib/src/turns-turn-order.c index abc22c4..552b200 100644 --- a/lib/src/turns-turn-order.c +++ b/lib/src/turns-turn-order.c @@ -10,10 +10,12 @@ #include <gio/gio.h> #include <glib-object.h> #include <glib.h> +#include <stdint.h> enum { PROP_EMPTY = 1, + PROP_PARTICIPANT_COUNT, PROP_RUNNING, PROP_SORT_MODE, N_PROPERTIES, @@ -111,6 +113,9 @@ static void turns_turn_order_get_property(GObject * self, guint id, GValue * val case PROP_EMPTY: g_value_set_boolean(value, turns_turn_order_get_empty(instance)); return; + case PROP_PARTICIPANT_COUNT: + g_value_set_uint64(value, turns_turn_order_get_participant_count(instance)); + return; case PROP_RUNNING: g_value_set_boolean(value, turns_turn_order_get_running(instance)); return; @@ -166,6 +171,14 @@ static void turns_turn_order_class_init(TurnsTurnOrderClass * klass) TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY); + properties[PROP_PARTICIPANT_COUNT] = g_param_spec_uint64("participant-count", + "Participant count", + "The number of participants in the turn order.", + 0, + UINT64_MAX, + 0, + G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY); + properties[PROP_RUNNING] = g_param_spec_boolean("running", "Running", "Whether or not the turn order is running (e.g. has been started)", diff --git a/lib/src/turnsmm/turn-order.cpp b/lib/src/turnsmm/turn-order.cpp index 5f38ded..d737679 100644 --- a/lib/src/turnsmm/turn-order.cpp +++ b/lib/src/turnsmm/turn-order.cpp @@ -141,12 +141,12 @@ namespace Turns auto TurnOrder::property_sort_mode() noexcept -> Glib::PropertyProxy<SortMode> { - return {this, "sort_mode"}; + return {this, "sort-mode"}; } auto TurnOrder::property_sort_mode() const noexcept -> Glib::PropertyProxy_ReadOnly<SortMode> { - return {this, "sort_mode"}; + return {this, "sort-mode"}; } TurnOrder::TurnOrder(BaseObjectType * gobj) diff --git a/lib/tests/turns-turn-order.cpp b/lib/tests/turns-turn-order.cpp index 0c1afcc..a4576f7 100644 --- a/lib/tests/turns-turn-order.cpp +++ b/lib/tests/turns-turn-order.cpp @@ -42,6 +42,11 @@ SCENARIO("Creating a turn order", "[lib][object][lifetime]") THEN("its participant count is 0") { REQUIRE(turns_turn_order_get_participant_count(instance) == 0uz); + + auto property_value = decltype(turns_turn_order_get_participant_count(instance)){}; + g_object_get(instance, "participant-count", &property_value, nullptr); + + REQUIRE(property_value == 0uz); } THEN("its running state is false") @@ -100,7 +105,12 @@ SCENARIO("Modifying a turn order", "[lib][object][data]") THEN("its participant count is 1") { - REQUIRE(turns_turn_order_get_participant_count(instance) == 1); + REQUIRE(turns_turn_order_get_participant_count(instance) == 1uz); + + auto property_value = decltype(turns_turn_order_get_participant_count(instance)){}; + g_object_get(instance, "participant-count", &property_value, nullptr); + + REQUIRE(property_value == 1uz); } THEN("its running state is false") @@ -146,6 +156,11 @@ SCENARIO("Modifying a turn order", "[lib][object][data]") THEN("its participant count is 0") { REQUIRE(turns_turn_order_get_participant_count(instance) == 0); + + auto property_value = decltype(turns_turn_order_get_participant_count(instance)){}; + g_object_get(instance, "participant-count", &property_value, nullptr); + + REQUIRE(property_value == 0uz); } THEN("its running state is false") @@ -203,6 +218,11 @@ SCENARIO("Modifying a turn order", "[lib][object][data]") THEN("its participant count is 0") { REQUIRE(turns_turn_order_get_participant_count(instance) == 0); + + auto property_value = decltype(turns_turn_order_get_participant_count(instance)){}; + g_object_get(instance, "participant-count", &property_value, nullptr); + + REQUIRE(property_value == 0uz); } THEN("the items-changed notification is emitted") @@ -243,6 +263,11 @@ SCENARIO("Modifying a turn order", "[lib][object][data]") THEN("its participant count is 0") { REQUIRE(turns_turn_order_get_participant_count(instance) == 0); + + auto property_value = decltype(turns_turn_order_get_participant_count(instance)){}; + g_object_get(instance, "participant-count", &property_value, nullptr); + + REQUIRE(property_value == 0uz); } THEN("the items-changed notification is not emitted") diff --git a/lib/tests/turnsmm/turn-order.cpp b/lib/tests/turnsmm/turn-order.cpp index eeee1c6..59b372a 100644 --- a/lib/tests/turnsmm/turn-order.cpp +++ b/lib/tests/turnsmm/turn-order.cpp @@ -36,7 +36,7 @@ SCENARIO("Creating a turn order", "[lib][object][lifetime]") THEN("its participant count is 0") { REQUIRE(instance.get_participant_count() == 0uz); - REQUIRE(instance.get_property<std::size_t>("participant-count") == 0); + REQUIRE(instance.get_property<std::size_t>("participant-count") == 0uz); REQUIRE_FALSE(list_model_notification.has_value()); } @@ -91,6 +91,7 @@ SCENARIO("Modifying a turn order", "[lib][object][data]") THEN("its participant count is 1") { REQUIRE(instance.get_participant_count() == 1); + REQUIRE(instance.get_property<std::size_t>("participant-count") == 1uz); } THEN("its running state is false") @@ -138,7 +139,7 @@ SCENARIO("Modifying a turn order", "[lib][object][data]") THEN("its participant count is 0") { REQUIRE(instance.get_participant_count() == 0uz); - REQUIRE(instance.get_property<std::size_t>("participant-count") == 0); + REQUIRE(instance.get_property<std::size_t>("participant-count") == 0uz); } THEN("its running state is false") @@ -186,6 +187,7 @@ SCENARIO("Modifying a turn order", "[lib][object][data]") THEN("its participant count is 0") { REQUIRE(instance.get_participant_count() == 0); + REQUIRE(instance.get_property<std::size_t>("participant-count") == 0uz); } THEN("the items-changed notification is emitted") @@ -210,6 +212,7 @@ SCENARIO("Modifying a turn order", "[lib][object][data]") THEN("its participant count is 0") { REQUIRE(instance.get_participant_count() == 0); + REQUIRE(instance.get_property<std::size_t>("participant-count") == 0uz); } THEN("the items-changed notification is not emitted") |
