8#include "../../../../tests/testXWC.hpp"
10#include "../../MagAOXApp.hpp"
11#include "../stdMotionStage.hpp"
145 const std::vector<std::pair<std::string, pcf::IndiElement::SwitchStateType>> &elements )
147 pcf::IndiProperty
ip( pcf::IndiProperty::Switch );
149 ip.setName(
"presetName" );
151 for(
const auto &element : elements )
153 ip.add( pcf::IndiElement( element.first ) );
154 ip[element.first].setSwitchState( element.second );
185template <
typename logT,
int retval>
189 logT::msgString(
const_cast<uint8_t *
>(
msg.builder.GetBufferPointer() ),
msg.builder.GetSize() );
238TEST_CASE(
"stdMotionStage rejects invalid preset-name selections",
"[dev::stdMotionStage]" )
241 #ifdef STDMOTIONSTAGE_TEST_DOXYGEN_REF
246 SECTION(
"quoted preset names are logged and rejected" )
257 REQUIRE( app.moveCalls() == 0 );
258 REQUIRE( app.lastMoveTarget() == -1.0f );
261 SECTION(
"invalid names are rejected even when a valid preset is also selected" )
269 { {
"open", pcf::IndiElement::On }, {
"bogus", pcf::IndiElement::On } } ) == -1 );
The base-class for XWCTk applications.
std::string m_configName
The name of the configuration file (minus .conf).
MagAO-X standard motion stage interface.
std::vector< std::string > m_presetNames
The names of each position on the stage.
std::string m_presetNotation
Notation used to refer to a preset, should be singular, as in "preset" or "filter".
pcf::IndiProperty m_indiP_presetName
The name of the active preset selection.
int newCallBack_m_indiP_presetName(const pcf::IndiProperty &ipRecv)
Callback to process a NEW preset name request.
Test harness for exercising stdMotionStage preset-name callbacks without the INDI validation short-ci...
static int logCount()
Get the number of stdMotionStage log messages captured by the harness.
int stop()
No-op stop implementation required by stdMotionStage for testing.
static std::string s_lastLogMessage
Most recent text log message captured from stdMotionStage.
int appStartup() override
No-op startup implementation required by MagAOXApp for testing.
static void resetLogState()
Reset the captured stdMotionStage logging state shared across harness instances.
stdMotionStageHarness()
Construct a stdMotionStage test harness with a presetName callback property.
void configurePresets(const std::vector< std::string > &presetNames, const std::string &presetNotation)
Configure the preset-name list and notation used by stdMotionStage.
int moveTo(float target)
Record a requested move target when stdMotionStage accepts a motion request.
static logPrioT lastLogLevel()
Get the most recent stdMotionStage log priority captured by the harness.
int startHoming()
No-op homing implementation required by stdMotionStage for testing.
int moveCalls() const
Get the number of move requests accepted by stdMotionStage.
int m_moveCalls
Number of motion requests issued by the helper.
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Capture stdMotionStage log messages instead of sending them to the normal logger.
static logPrioT s_lastLogLevel
Most recent log priority captured from stdMotionStage.
float m_lastMoveTarget
Last target passed to moveTo by the helper.
int appShutdown() override
No-op shutdown implementation required by MagAOXApp for testing.
float lastMoveTarget() const
Get the last move target accepted by stdMotionStage.
static const std::string & lastLogMessage()
Get the most recent stdMotionStage text log message captured by the harness.
~stdMotionStageHarness() noexcept override
Destroy the stdMotionStage test harness.
float presetNumber()
Return a fixed preset number for testing paths that query the current preset.
static int s_logCount
Number of captured stdMotionStage log messages.
int appLogic() override
No-op logic implementation required by MagAOXApp for testing.
int applyPresetNameRequest(const std::vector< std::pair< std::string, pcf::IndiElement::SwitchStateType > > &elements)
Apply a presetName request property to the stdMotionStage callback under test.
int8_t logPrioT
The type of the log priority code.
TEST_CASE("stdMotionStage rejects invalid preset-name selections", "[dev::stdMotionStage]")
Verify stdMotionStage logs and rejects invalid preset-name selections before issuing motion requests.
static constexpr logPrioT LOG_ERROR
An error has occured which the software will attempt to correct.
static constexpr logPrioT LOG_DEFAULT
Used to denote "use the default level for this log type".
Namespace for all libXWC tests.