154 SECTION(
"using default paths, configname is invoked name" )
156 std::vector<std::string> argvstr( {
"./execname" } );
158 std::vector<const char *> argv( argvstr.size() + 1, NULL );
159 for(
size_t index = 0; index < argvstr.size(); ++index )
161 argv[index] = argvstr[index].c_str();
167 REQUIRE( app.
doHelp() ==
false );
168 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
169 REQUIRE( app.
doHelp() ==
true );
186 REQUIRE( app.configBase() ==
"" );
188 REQUIRE( app.configName() ==
"execname" );
189 REQUIRE( app.
configPathLocal() == app.configDir() +
"/execname.conf" );
191 REQUIRE( app.
doHelp() ==
true );
194 SECTION(
"using default paths, with config-ed name" )
196 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
198 std::vector<const char *> argv( argvstr.size() + 1, NULL );
199 for(
size_t index = 0; index < argvstr.size(); ++index )
201 argv[index] = argvstr[index].c_str();
207 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
218 REQUIRE( app.configBase() ==
"" );
220 REQUIRE( app.configName() ==
"testapp" );
222 REQUIRE( app.
doHelp() ==
false );
227 SECTION(
"using environment paths, with config-ed name" )
229 std::vector<const char *> argv;
230 std::vector<std::string> argvstr( {
"./execname",
"--name",
"testapp2" } );
232 argv.resize( argvstr.size() + 1, NULL );
233 for(
size_t index = 0; index < argvstr.size(); ++index )
235 argv[index] = argvstr[index].c_str();
239 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
255 snprintf( syspath,
sizeof( syspath ),
"%s=sys2",
MAGAOX_env_sys );
258 char secretspath[1024];
260 putenv( secretspath );
263 snprintf( cpupath,
sizeof( cpupath ),
"%s=/tmp/MagAOX/cpuset",
MAGAOX_env_cpuset );
271 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
273 REQUIRE( app.basePath() ==
"/tmp/MagAOXApp_test" );
274 REQUIRE( app.configDir() == app.basePath() +
'/' +
"config2" );
276 REQUIRE( app.calibDir() == app.basePath() +
'/' +
"calib2" );
277 REQUIRE( app.m_log.logPath() == app.basePath() +
'/' +
"logs2" );
278 REQUIRE( app.sysPath() == app.basePath() +
'/' +
"sys2" );
279 REQUIRE( app.secretsPath() == app.basePath() +
'/' +
"secrets2" );
280 REQUIRE( app.cpusetPath() ==
"/tmp/MagAOX/cpuset" );
281 REQUIRE( app.configBase() ==
"cbase" );
282 REQUIRE( app.
configPathUser() == app.configDir() +
"/cbase.conf" );
283 REQUIRE( app.configName() ==
"testapp2" );
284 REQUIRE( app.
configPathLocal() == app.configDir() +
"/testapp2.conf" );
285 REQUIRE( app.
doHelp() ==
false );
295 SECTION(
"setup basic config" )
300 app.setupBasicConfig();
302 REQUIRE( app.shutdown() ==
false );
305 SECTION(
"load basic config w all defaults w/out pwr management" )
310 app.setupBasicConfig();
312 app.loadBasicConfig();
316 REQUIRE( app.stateAlert() ==
false );
317 REQUIRE( app.gitAlert() ==
false );
318 REQUIRE( app.shutdown() ==
false );
321 SECTION(
"load basic config w all defaults w/out pwr management, setting state and clearing alerts" )
323 std::vector<const char *> argv;
324 std::vector<std::string> argvstr( {
"./execname",
"--name",
"testapp" } );
326 argv.resize( argvstr.size() + 1, NULL );
327 for(
size_t index = 0; index < argvstr.size(); ++index )
329 argv[index] = argvstr[index].c_str();
335 app.setupBasicConfig();
337 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
339 app.loadBasicConfig();
343 REQUIRE( app.stateAlert() ==
true );
344 REQUIRE( app.gitAlert() ==
true );
345 REQUIRE( app.shutdown() ==
false );
348 REQUIRE( app.stateAlert() ==
false );
349 REQUIRE( app.gitAlert() ==
true );
350 REQUIRE( app.shutdown() ==
false );
358 REQUIRE( app.stateLogged() == 0 );
359 REQUIRE( app.stateLogged() == 1 );
362 REQUIRE( app.stateAlert() ==
true );
365 REQUIRE( app.stateAlert() ==
false );
371 REQUIRE( app.stateAlert() ==
true );
374 REQUIRE( app.stateAlert() ==
false );
380 REQUIRE( app.stateAlert() ==
true );
383 REQUIRE( app.stateAlert() ==
false );
389 REQUIRE( app.stateAlert() ==
true );
392 REQUIRE( app.stateAlert() ==
false );
398 REQUIRE( app.stateAlert() ==
true );
401 REQUIRE( app.stateAlert() ==
false );
407 REQUIRE( app.stateAlert() ==
true );
410 REQUIRE( app.stateAlert() ==
false );
413 SECTION(
"load basic config w all defaults w unconfigured pwr management" )
418 app.setupBasicConfig();
420 app.loadBasicConfig();
422 REQUIRE( app.shutdown() ==
true );
426 REQUIRE( app.stateAlert() ==
false );
427 REQUIRE( app.gitAlert() ==
false );
428 REQUIRE( app.shutdown() ==
true );
431 SECTION(
"load a full config" )
433 std::vector<const char *> argv;
434 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp",
"--config.validate" } );
436 argv.resize( argvstr.size() + 1, NULL );
437 for(
size_t index = 0; index < argvstr.size(); ++index )
439 argv[index] = argvstr[index].c_str();
443 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
446 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
449 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
452 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
453 {
"",
"power",
"power",
"power",
"power",
"power" },
454 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
455 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500000" } );
458 app.setPowerMgtEnabled(
true );
460 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
462 REQUIRE( app.stateAlert() ==
true );
463 REQUIRE( app.configOnly() ==
true );
464 REQUIRE( app.loopPause() == 2500 );
465 REQUIRE( app.powerDevice() ==
"pdu9" );
466 REQUIRE( app.powerChannel() ==
"thisch" );
467 REQUIRE( app.powerElement() ==
"thisel" );
468 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
469 REQUIRE( app.powerOnWait() == 0 );
471 REQUIRE( app.shutdown() ==
false );
474 SECTION(
"load a full config w unknown config in file, do help" )
476 std::vector<const char *> argv;
477 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
479 argv.resize( argvstr.size() + 1, NULL );
480 for(
size_t index = 0; index < argvstr.size(); ++index )
482 argv[index] = argvstr[index].c_str();
486 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
489 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
492 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
496 mx::app::writeConfigFile(
497 "/tmp/MagAOXApp_test/config/testapp.conf",
498 {
"",
"power",
"power",
"power",
"power",
"power",
"" },
499 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait",
"unknown" },
500 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500",
"value" } );
503 app.setPowerMgtEnabled(
true );
505 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
507 REQUIRE( app.stateAlert() ==
false );
508 REQUIRE( app.configOnly() ==
false );
509 REQUIRE( app.loopPause() == 2500 );
510 REQUIRE( app.powerDevice() ==
"pdu9" );
511 REQUIRE( app.powerChannel() ==
"thisch" );
512 REQUIRE( app.powerElement() ==
"thisel" );
513 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
514 REQUIRE( app.powerOnWait() == 500 );
516 REQUIRE( app.doHelp() ==
true );
517 REQUIRE( app.shutdown() ==
true );
520 SECTION(
"load a full config w unknown config in file, validate" )
522 std::vector<const char *> argv;
523 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp",
"--config.validate" } );
525 argv.resize( argvstr.size() + 1, NULL );
526 for(
size_t index = 0; index < argvstr.size(); ++index )
528 argv[index] = argvstr[index].c_str();
532 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
535 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
538 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
542 mx::app::writeConfigFile(
543 "/tmp/MagAOXApp_test/config/testapp.conf",
544 {
"",
"power",
"power",
"power",
"power",
"power",
"" },
545 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait",
"unknown" },
546 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500000",
"value" } );
549 app.setPowerMgtEnabled(
true );
551 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
553 REQUIRE( app.stateAlert() ==
true );
554 REQUIRE( app.configOnly() ==
true );
555 REQUIRE( app.loopPause() == 2500 );
556 REQUIRE( app.powerDevice() ==
"pdu9" );
557 REQUIRE( app.powerChannel() ==
"thisch" );
558 REQUIRE( app.powerElement() ==
"thisel" );
559 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
560 REQUIRE( app.powerOnWait() == 0 );
562 REQUIRE( app.doHelp() ==
false );
563 REQUIRE( app.shutdown() ==
true );
566 SECTION(
"load a full config w non-option clopt" )
568 std::vector<const char *> argv;
569 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp",
"straylight" } );
571 argv.resize( argvstr.size() + 1, NULL );
572 for(
size_t index = 0; index < argvstr.size(); ++index )
574 argv[index] = argvstr[index].c_str();
578 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
581 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
584 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
587 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
588 {
"",
"power",
"power",
"power",
"power",
"power" },
589 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
590 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500000" } );
593 app.setPowerMgtEnabled(
true );
595 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
597 REQUIRE( app.stateAlert() ==
false );
598 REQUIRE( app.configOnly() ==
false );
599 REQUIRE( app.loopPause() == 2500 );
600 REQUIRE( app.powerDevice() ==
"pdu9" );
601 REQUIRE( app.powerChannel() ==
"thisch" );
602 REQUIRE( app.powerElement() ==
"thisel" );
603 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
604 REQUIRE( app.powerOnWait() == 0 );
606 REQUIRE( app.doHelp() ==
true );
607 REQUIRE( app.shutdown() ==
true );
610 SECTION(
"load a full config w no power mgt opts" )
612 std::vector<const char *> argv;
613 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
615 argv.resize( argvstr.size() + 1, NULL );
616 for(
size_t index = 0; index < argvstr.size(); ++index )
618 argv[index] = argvstr[index].c_str();
622 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
625 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
628 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
631 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf", {
"" }, {
"loopPause" }, {
"2500" } );
634 app.setPowerMgtEnabled(
true );
636 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
638 REQUIRE( app.stateAlert() ==
false );
639 REQUIRE( app.configOnly() ==
false );
640 REQUIRE( app.loopPause() == 2500 );
641 REQUIRE( app.powerDevice() ==
"" );
642 REQUIRE( app.powerChannel() ==
"" );
643 REQUIRE( app.powerElement() ==
"state" );
644 REQUIRE( app.powerTargetElement() ==
"target" );
645 REQUIRE( app.powerOnWait() == 0 );
647 REQUIRE( app.doHelp() ==
true );
648 REQUIRE( app.shutdown() ==
true );
651 SECTION(
"load a full config w unused config options" )
653 std::vector<const char *> argv;
654 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp",
"--config.validate" } );
656 argv.resize( argvstr.size() + 1, NULL );
657 for(
size_t index = 0; index < argvstr.size(); ++index )
659 argv[index] = argvstr[index].c_str();
663 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
666 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
669 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
673 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
674 {
"",
"power",
"power",
"power",
"power",
"power" },
675 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
676 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500000" } );
679 app.setPowerMgtEnabled(
true );
681 app.addUnusedConfig();
683 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
685 REQUIRE( app.stateAlert() ==
true );
686 REQUIRE( app.configOnly() ==
true );
687 REQUIRE( app.loopPause() == 2500 );
688 REQUIRE( app.powerDevice() ==
"pdu9" );
689 REQUIRE( app.powerChannel() ==
"thisch" );
690 REQUIRE( app.powerElement() ==
"thisel" );
691 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
692 REQUIRE( app.powerOnWait() == 0 );
694 REQUIRE( app.doHelp() ==
false );
695 REQUIRE( app.shutdown() ==
false );
705 SECTION(
"Basic PID Lock" )
707 std::vector<const char *> argv;
708 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
710 argv.resize( argvstr.size() + 1, NULL );
711 for(
size_t index = 0; index < argvstr.size(); ++index )
713 argv[index] = argvstr[index].c_str();
717 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
720 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/" );
723 std::filesystem::remove_all(
"/tmp/MagAOXApp_test/sys/testapp" );
727 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
729 REQUIRE( !std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
733 REQUIRE( std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
737 REQUIRE( !std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
740 SECTION(
"PID Lock, app directory creation error" )
742 std::vector<const char *> argv;
743 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
745 argv.resize( argvstr.size() + 1, NULL );
746 for(
size_t index = 0; index < argvstr.size(); ++index )
748 argv[index] = argvstr[index].c_str();
752 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
756 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
760 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
769 SECTION(
"Stale lock" )
771 std::vector<const char *> argv;
772 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
774 argv.resize( argvstr.size() + 1, NULL );
775 for(
size_t index = 0; index < argvstr.size(); ++index )
777 argv[index] = argvstr[index].c_str();
781 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
784 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
787 fout.open(
"/tmp/MagAOXApp_test/sys/testapp/pid" );
793 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
797 REQUIRE( std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
801 REQUIRE( !std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
804 SECTION(
"already locked" )
806 std::vector<const char *> argv;
807 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
809 argv.resize( argvstr.size() + 1, NULL );
810 for(
size_t index = 0; index < argvstr.size(); ++index )
812 argv[index] = argvstr[index].c_str();
816 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
819 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
822 fout.open(
"/tmp/MagAOXApp_test/sys/testapp/pid" );
826 XWCTEST_MAGAOXAPP_PID_LOCKED_ns::MagAOXApp_test app;
827 app.invokedName() = argv[0];
828 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
830 int rv = app.lockPID();
834 SECTION(
"write fails" )
836 std::vector<const char *> argv;
837 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
839 argv.resize( argvstr.size() + 1, NULL );
840 for(
size_t index = 0; index < argvstr.size(); ++index )
842 argv[index] = argvstr[index].c_str();
846 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
849 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
852 fout.open(
"/tmp/MagAOXApp_test/sys/testapp/pid" );
856 XWCTEST_MAGAOXAPP_PID_WRITE_FAIL_ns::MagAOXApp_test app;
857 app.invokedName() = argv[0];
858 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
860 int rv = app.lockPID();
944TEST_CASE(
"INDI preperty creation utilities",
"[app::MagAOXApp]" )
946 SECTION(
"createStandardIndiText" )
951 pcf::IndiProperty ip;
953 app.createStandardIndiText( ip,
"tprop",
"tlabel",
"tgroup" );
955 REQUIRE( ip.getType() == pcf::IndiProperty::Text );
956 REQUIRE( ip.getDevice() ==
"test" );
957 REQUIRE( ip.getName() ==
"tprop" );
958 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
959 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
960 REQUIRE( ip.find(
"current" ) ==
true );
961 REQUIRE( ip.find(
"target" ) ==
true );
962 REQUIRE( ip.getLabel() ==
"tlabel" );
963 REQUIRE( ip.getGroup() ==
"tgroup" );
966 SECTION(
"createROIndiText" )
971 pcf::IndiProperty ip;
973 app.createROIndiText( ip,
"tprop",
"tel",
"tlabel",
"tgroup",
"ellabel" );
975 REQUIRE( ip.getType() == pcf::IndiProperty::Text );
976 REQUIRE( ip.getDevice() ==
"test" );
977 REQUIRE( ip.getName() ==
"tprop" );
978 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadOnly );
979 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
980 REQUIRE( ip.getLabel() ==
"tlabel" );
981 REQUIRE( ip.getGroup() ==
"tgroup" );
983 REQUIRE( ip.find(
"tel" ) ==
true );
984 REQUIRE( ip[
"tel"].getLabel() ==
"ellabel" );
987 SECTION(
"createStandardIndiNumber" )
992 pcf::IndiProperty ip;
994 app.createStandardIndiNumber<
double>( ip,
"tprop", 0.001, 1, 0.002,
"%0.23g",
"tlabel",
"tgroup" );
996 REQUIRE( ip.getType() == pcf::IndiProperty::Number );
997 REQUIRE( ip.getDevice() ==
"test" );
998 REQUIRE( ip.getName() ==
"tprop" );
999 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1000 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1002 REQUIRE( ip.find(
"current" ) ==
true );
1003 REQUIRE( ip[
"current"].getMin() ==
"0.001" );
1004 REQUIRE( ip[
"current"].getMax() ==
"1" );
1005 REQUIRE( ip[
"current"].getStep() ==
"0.002" );
1006 REQUIRE( ip[
"current"].getFormat() ==
"%0.23g" );
1008 REQUIRE( ip.find(
"target" ) ==
true );
1009 REQUIRE( ip[
"target"].getMin() ==
"0.001" );
1010 REQUIRE( ip[
"target"].getMax() ==
"1" );
1011 REQUIRE( ip[
"target"].getStep() ==
"0.002" );
1012 REQUIRE( ip[
"target"].getFormat() ==
"%0.23g" );
1014 REQUIRE( ip.getLabel() ==
"tlabel" );
1015 REQUIRE( ip.getGroup() ==
"tgroup" );
1018 SECTION(
"createROIndiNumber" )
1023 pcf::IndiProperty ip;
1025 app.createROIndiNumber( ip,
"tprop",
"tlabel",
"tgroup" );
1027 REQUIRE( ip.getType() == pcf::IndiProperty::Number );
1028 REQUIRE( ip.getDevice() ==
"test" );
1029 REQUIRE( ip.getName() ==
"tprop" );
1030 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadOnly );
1031 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1032 REQUIRE( ip.getLabel() ==
"tlabel" );
1033 REQUIRE( ip.getGroup() ==
"tgroup" );
1036 SECTION(
"createStandardIndiToggleSw" )
1041 pcf::IndiProperty ip;
1043 app.createStandardIndiToggleSw( ip,
"tpropz",
"tlabelz",
"tgroupz" );
1045 REQUIRE( ip.getType() == pcf::IndiProperty::Switch );
1046 REQUIRE( ip.getDevice() ==
"testz" );
1047 REQUIRE( ip.getName() ==
"tpropz" );
1048 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1049 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1050 REQUIRE( ip.getRule() == pcf::IndiProperty::AtMostOne );
1052 REQUIRE( ip.getNumElements() == 1 );
1053 REQUIRE( ip.find(
"toggle" ) ==
true );
1054 REQUIRE( ip[
"toggle"].getSwitchState() == pcf::IndiElement::Off );
1055 REQUIRE( ip.getLabel() ==
"tlabelz" );
1056 REQUIRE( ip.getGroup() ==
"tgroupz" );
1059 SECTION(
"createStandardIndiRequestSw" )
1064 pcf::IndiProperty ip;
1066 app.createStandardIndiRequestSw( ip,
"tpropz",
"tlabelz",
"tgroupz" );
1068 REQUIRE( ip.getType() == pcf::IndiProperty::Switch );
1069 REQUIRE( ip.getDevice() ==
"testz" );
1070 REQUIRE( ip.getName() ==
"tpropz" );
1071 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1072 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1073 REQUIRE( ip.getRule() == pcf::IndiProperty::AtMostOne );
1075 REQUIRE( ip.getNumElements() == 1 );
1076 REQUIRE( ip.find(
"request" ) ==
true );
1077 REQUIRE( ip[
"request"].getSwitchState() == pcf::IndiElement::Off );
1078 REQUIRE( ip.getLabel() ==
"tlabelz" );
1079 REQUIRE( ip.getGroup() ==
"tgroupz" );
1082 SECTION(
"createStandardIndiSelectionSw, w/ labels" )
1087 pcf::IndiProperty ip;
1089 std::vector<std::string> els( {
"el1",
"el2",
"el3" } );
1090 std::vector<std::string> labs( {
"l1",
"",
"l3" } );
1092 app.createStandardIndiSelectionSw( ip,
"tpropy", els, labs,
"tlabely",
"tgroupy" );
1094 REQUIRE( ip.getType() == pcf::IndiProperty::Switch );
1095 REQUIRE( ip.getDevice() ==
"testy" );
1096 REQUIRE( ip.getName() ==
"tpropy" );
1097 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1098 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1099 REQUIRE( ip.getRule() == pcf::IndiProperty::OneOfMany );
1101 REQUIRE( ip.getNumElements() == 3 );
1102 REQUIRE( ip.find(
"el1" ) ==
true );
1103 REQUIRE( ip[
"el1"].getSwitchState() == pcf::IndiElement::Off );
1104 REQUIRE( ip[
"el1"].getLabel() ==
"l1" );
1106 REQUIRE( ip.find(
"el2" ) ==
true );
1107 REQUIRE( ip[
"el2"].getSwitchState() == pcf::IndiElement::Off );
1108 REQUIRE( ip[
"el2"].getLabel() ==
"" );
1110 REQUIRE( ip.find(
"el3" ) ==
true );
1111 REQUIRE( ip[
"el3"].getSwitchState() == pcf::IndiElement::Off );
1112 REQUIRE( ip[
"el3"].getLabel() ==
"l3" );
1114 REQUIRE( ip.getLabel() ==
"tlabely" );
1115 REQUIRE( ip.getGroup() ==
"tgroupy" );
1118 SECTION(
"createStandardIndiSelectionSw, no labels" )
1123 pcf::IndiProperty ip;
1125 std::vector<std::string> els( {
"el1",
"el2",
"el3" } );
1127 app.createStandardIndiSelectionSw( ip,
"tpropy", els,
"tlabely",
"tgroupy" );
1129 REQUIRE( ip.getType() == pcf::IndiProperty::Switch );
1130 REQUIRE( ip.getDevice() ==
"testy" );
1131 REQUIRE( ip.getName() ==
"tpropy" );
1132 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1133 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1134 REQUIRE( ip.getRule() == pcf::IndiProperty::OneOfMany );
1136 REQUIRE( ip.getNumElements() == 3 );
1137 REQUIRE( ip.find(
"el1" ) ==
true );
1138 REQUIRE( ip[
"el1"].getSwitchState() == pcf::IndiElement::Off );
1139 REQUIRE( ip[
"el1"].getLabel() ==
"el1" );
1141 REQUIRE( ip.find(
"el2" ) ==
true );
1142 REQUIRE( ip[
"el2"].getSwitchState() == pcf::IndiElement::Off );
1143 REQUIRE( ip[
"el2"].getLabel() ==
"el2" );
1145 REQUIRE( ip.find(
"el3" ) ==
true );
1146 REQUIRE( ip[
"el3"].getSwitchState() == pcf::IndiElement::Off );
1147 REQUIRE( ip[
"el3"].getLabel() ==
"el3" );
1149 REQUIRE( ip.getLabel() ==
"tlabely" );
1150 REQUIRE( ip.getGroup() ==
"tgroupy" );