From 059831534c7e884f0a607ed86b582fd00d821731 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Sat, 26 Sep 2026 23:24:03 +0200 Subject: New upstream version 3.2.0~rc1+dfsg --- tests/unit/common/test_hamlib_vfo_role_state.cpp | 83 ++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/unit/common/test_hamlib_vfo_role_state.cpp (limited to 'tests/unit/common/test_hamlib_vfo_role_state.cpp') 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 + +#include + +#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" -- cgit v1.2.3