summaryrefslogtreecommitdiff
path: root/tests/unit/common/test_hamlib_vfo_role_state.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
commit69344560ea394c06ca94acac46a2e4c3e8b7b229 (patch)
treeebc98370a697a9bbd6b973a14fa5113c475c6db7 /tests/unit/common/test_hamlib_vfo_role_state.cpp
parent3e9d10a67671d0bd5c7b8c3ca8088f1818322eff (diff)
parent059831534c7e884f0a607ed86b582fd00d821731 (diff)
Update upstream source from tag 'upstream/3.2.0_rc1+dfsg'
Update to upstream version '3.2.0~rc1+dfsg' with Debian dir dbff457fd2c3616d5c77b863c7bfb2186ed86047
Diffstat (limited to 'tests/unit/common/test_hamlib_vfo_role_state.cpp')
-rw-r--r--tests/unit/common/test_hamlib_vfo_role_state.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/unit/common/test_hamlib_vfo_role_state.cpp b/tests/unit/common/test_hamlib_vfo_role_state.cpp
new file mode 100644
index 00000000..44edb39a
--- /dev/null
+++ b/tests/unit/common/test_hamlib_vfo_role_state.cpp
@@ -0,0 +1,83 @@
+#include <tuple>
+
+#include <QtTest>
+
+#include "Transceiver/HamlibVfoRoleState.hpp"
+
+class TestHamlibVfoRoleState : public QObject
+{
+ Q_OBJECT
+
+private:
+ Q_SLOT void receivingOnVfoAUsesNormalRoles ()
+ {
+ HamlibVfoRoleState state;
+ state.observe_active_vfo (RIG_VFO_A, false);
+
+ auto const vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_A);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_B);
+ }
+
+ Q_SLOT void receivingOnVfoBReversesRoles ()
+ {
+ HamlibVfoRoleState state;
+ state.observe_active_vfo (RIG_VFO_B, false);
+
+ auto const vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_B);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_A);
+ }
+
+ Q_SLOT void splitPttPreservesNormalRoles ()
+ {
+ HamlibVfoRoleState state;
+ state.observe_active_vfo (RIG_VFO_A, false);
+ state.observe_active_vfo (RIG_VFO_B, true);
+
+ auto const vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_A);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_B);
+ }
+
+ Q_SLOT void splitPttPreservesReversedRoles ()
+ {
+ HamlibVfoRoleState state;
+ state.observe_active_vfo (RIG_VFO_B, false);
+ state.observe_active_vfo (RIG_VFO_A, true);
+
+ auto const vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_B);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_A);
+ }
+
+ Q_SLOT void observationResumesAfterSplitPtt ()
+ {
+ HamlibVfoRoleState state;
+ state.observe_active_vfo (RIG_VFO_A, false);
+ state.observe_active_vfo (RIG_VFO_B, true);
+ state.observe_active_vfo (RIG_VFO_B, false);
+
+ auto const vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_B);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_A);
+ }
+
+ Q_SLOT void resetRestoresNormalRoles ()
+ {
+ HamlibVfoRoleState state;
+ auto vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_A);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_B);
+
+ state.observe_active_vfo (RIG_VFO_B, false);
+ state.reset ();
+
+ vfos = state.resolve (RIG_VFO_A, RIG_VFO_B);
+ QCOMPARE (std::get<0> (vfos), RIG_VFO_A);
+ QCOMPARE (std::get<1> (vfos), RIG_VFO_B);
+ }
+};
+
+QTEST_APPLESS_MAIN (TestHamlibVfoRoleState)
+#include "test_hamlib_vfo_role_state.moc"