225 SECTION(
"using default paths, configname is invoked name" )
227 std::vector<std::string> argvstr( {
"./execname" } );
229 std::vector<const char *> argv( argvstr.size() + 1, NULL );
230 for(
size_t index = 0; index < argvstr.size(); ++index )
232 argv[index] = argvstr[index].c_str();
238 REQUIRE( app.
doHelp() ==
false );
239 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
240 REQUIRE( app.
doHelp() ==
true );
257 REQUIRE( app.configBase() ==
"" );
259 REQUIRE( app.configName() ==
"execname" );
260 REQUIRE( app.
configPathLocal() == app.configDir() +
"/execname.conf" );
262 REQUIRE( app.
doHelp() ==
true );
265 SECTION(
"using default paths, with config-ed name" )
267 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
269 std::vector<const char *> argv( argvstr.size() + 1, NULL );
270 for(
size_t index = 0; index < argvstr.size(); ++index )
272 argv[index] = argvstr[index].c_str();
278 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
289 REQUIRE( app.configBase() ==
"" );
291 REQUIRE( app.configName() ==
"testapp" );
293 REQUIRE( app.
doHelp() ==
false );
298 SECTION(
"using environment paths, with config-ed name" )
300 std::vector<const char *> argv;
301 std::vector<std::string> argvstr( {
"./execname",
"--name",
"testapp2" } );
303 argv.resize( argvstr.size() + 1, NULL );
304 for(
size_t index = 0; index < argvstr.size(); ++index )
306 argv[index] = argvstr[index].c_str();
310 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
326 snprintf( syspath,
sizeof( syspath ),
"%s=sys2",
MAGAOX_env_sys );
329 char secretspath[1024];
331 putenv( secretspath );
334 snprintf( cpupath,
sizeof( cpupath ),
"%s=/tmp/MagAOX/cpuset",
MAGAOX_env_cpuset );
342 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
344 REQUIRE( app.basePath() ==
"/tmp/MagAOXApp_test" );
345 REQUIRE( app.configDir() == app.basePath() +
'/' +
"config2" );
347 REQUIRE( app.calibDir() == app.basePath() +
'/' +
"calib2" );
348 REQUIRE( app.m_log.logPath() == app.basePath() +
'/' +
"logs2" );
349 REQUIRE( app.sysPath() == app.basePath() +
'/' +
"sys2" );
350 REQUIRE( app.secretsPath() == app.basePath() +
'/' +
"secrets2" );
351 REQUIRE( app.cpusetPath() ==
"/tmp/MagAOX/cpuset" );
352 REQUIRE( app.configBase() ==
"cbase" );
353 REQUIRE( app.
configPathUser() == app.configDir() +
"/cbase.conf" );
354 REQUIRE( app.configName() ==
"testapp2" );
355 REQUIRE( app.
configPathLocal() == app.configDir() +
"/testapp2.conf" );
356 REQUIRE( app.
doHelp() ==
false );
366 SECTION(
"setup basic config" )
371 app.setupBasicConfig();
373 REQUIRE( app.shutdown() ==
false );
376 SECTION(
"load basic config w all defaults w/out pwr management" )
381 app.setupBasicConfig();
383 app.loadBasicConfig();
387 REQUIRE( app.stateAlert() ==
false );
388 REQUIRE( app.gitAlert() ==
false );
389 REQUIRE( app.shutdown() ==
false );
392 SECTION(
"load basic config w all defaults w/out pwr management, setting state and clearing alerts" )
394 std::vector<const char *> argv;
395 std::vector<std::string> argvstr( {
"./execname",
"--name",
"testapp" } );
397 argv.resize( argvstr.size() + 1, NULL );
398 for(
size_t index = 0; index < argvstr.size(); ++index )
400 argv[index] = argvstr[index].c_str();
406 app.setupBasicConfig();
408 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
410 app.loadBasicConfig();
414 REQUIRE( app.stateAlert() ==
true );
415 REQUIRE( app.gitAlert() ==
true );
416 REQUIRE( app.shutdown() ==
false );
419 REQUIRE( app.stateAlert() ==
false );
420 REQUIRE( app.gitAlert() ==
true );
421 REQUIRE( app.shutdown() ==
false );
429 REQUIRE( app.stateLogged() == 0 );
430 REQUIRE( app.stateLogged() == 1 );
433 REQUIRE( app.stateAlert() ==
true );
436 REQUIRE( app.stateAlert() ==
false );
442 REQUIRE( app.stateAlert() ==
true );
445 REQUIRE( app.stateAlert() ==
false );
451 REQUIRE( app.stateAlert() ==
true );
454 REQUIRE( app.stateAlert() ==
false );
460 REQUIRE( app.stateAlert() ==
true );
463 REQUIRE( app.stateAlert() ==
false );
469 REQUIRE( app.stateAlert() ==
true );
472 REQUIRE( app.stateAlert() ==
false );
478 REQUIRE( app.stateAlert() ==
true );
481 REQUIRE( app.stateAlert() ==
false );
484 SECTION(
"load basic config w all defaults w unconfigured pwr management" )
489 app.setupBasicConfig();
491 app.loadBasicConfig();
493 REQUIRE( app.shutdown() ==
true );
497 REQUIRE( app.stateAlert() ==
false );
498 REQUIRE( app.gitAlert() ==
false );
499 REQUIRE( app.shutdown() ==
true );
502 SECTION(
"load a full config" )
504 std::vector<const char *> argv;
505 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp",
"--config.validate" } );
507 argv.resize( argvstr.size() + 1, NULL );
508 for(
size_t index = 0; index < argvstr.size(); ++index )
510 argv[index] = argvstr[index].c_str();
514 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
517 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
520 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
523 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
524 {
"",
"power",
"power",
"power",
"power",
"power" },
525 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
526 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500000" } );
529 app.setPowerMgtEnabled(
true );
531 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
533 REQUIRE( app.stateAlert() ==
true );
534 REQUIRE( app.configOnly() ==
true );
535 REQUIRE( app.loopPause() == 2500 );
536 REQUIRE( app.powerDevice() ==
"pdu9" );
537 REQUIRE( app.powerChannel() ==
"thisch" );
538 REQUIRE( app.powerElement() ==
"thisel" );
539 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
540 REQUIRE( app.powerOnWait() == 0 );
542 REQUIRE( app.shutdown() ==
false );
545 SECTION(
"load a full config w unknown config in file, do help" )
547 std::vector<const char *> argv;
548 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
550 argv.resize( argvstr.size() + 1, NULL );
551 for(
size_t index = 0; index < argvstr.size(); ++index )
553 argv[index] = argvstr[index].c_str();
557 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
560 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
563 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
567 mx::app::writeConfigFile(
568 "/tmp/MagAOXApp_test/config/testapp.conf",
569 {
"",
"power",
"power",
"power",
"power",
"power",
"" },
570 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait",
"unknown" },
571 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500",
"value" } );
574 app.setPowerMgtEnabled(
true );
576 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
578 REQUIRE( app.stateAlert() ==
false );
579 REQUIRE( app.configOnly() ==
false );
580 REQUIRE( app.loopPause() == 2500 );
581 REQUIRE( app.powerDevice() ==
"pdu9" );
582 REQUIRE( app.powerChannel() ==
"thisch" );
583 REQUIRE( app.powerElement() ==
"thisel" );
584 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
585 REQUIRE( app.powerOnWait() == 500 );
587 REQUIRE( app.doHelp() ==
true );
588 REQUIRE( app.shutdown() ==
true );
591 SECTION(
"load a full config w unknown config in file, validate" )
593 std::vector<const char *> argv;
594 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp",
"--config.validate" } );
596 argv.resize( argvstr.size() + 1, NULL );
597 for(
size_t index = 0; index < argvstr.size(); ++index )
599 argv[index] = argvstr[index].c_str();
603 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
606 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
609 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
613 mx::app::writeConfigFile(
614 "/tmp/MagAOXApp_test/config/testapp.conf",
615 {
"",
"power",
"power",
"power",
"power",
"power",
"" },
616 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait",
"unknown" },
617 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500000",
"value" } );
620 app.setPowerMgtEnabled(
true );
622 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
624 REQUIRE( app.stateAlert() ==
true );
625 REQUIRE( app.configOnly() ==
true );
626 REQUIRE( app.loopPause() == 2500 );
627 REQUIRE( app.powerDevice() ==
"pdu9" );
628 REQUIRE( app.powerChannel() ==
"thisch" );
629 REQUIRE( app.powerElement() ==
"thisel" );
630 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
631 REQUIRE( app.powerOnWait() == 0 );
633 REQUIRE( app.doHelp() ==
false );
634 REQUIRE( app.shutdown() ==
true );
637 SECTION(
"load a full config w non-option clopt" )
639 std::vector<const char *> argv;
640 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp",
"straylight" } );
642 argv.resize( argvstr.size() + 1, NULL );
643 for(
size_t index = 0; index < argvstr.size(); ++index )
645 argv[index] = argvstr[index].c_str();
649 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
652 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
655 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
658 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
659 {
"",
"power",
"power",
"power",
"power",
"power" },
660 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
661 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500000" } );
664 app.setPowerMgtEnabled(
true );
666 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
668 REQUIRE( app.stateAlert() ==
false );
669 REQUIRE( app.configOnly() ==
false );
670 REQUIRE( app.loopPause() == 2500 );
671 REQUIRE( app.powerDevice() ==
"pdu9" );
672 REQUIRE( app.powerChannel() ==
"thisch" );
673 REQUIRE( app.powerElement() ==
"thisel" );
674 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
675 REQUIRE( app.powerOnWait() == 0 );
677 REQUIRE( app.doHelp() ==
true );
678 REQUIRE( app.shutdown() ==
true );
681 SECTION(
"load a full config w no power mgt opts" )
683 std::vector<const char *> argv;
684 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
686 argv.resize( argvstr.size() + 1, NULL );
687 for(
size_t index = 0; index < argvstr.size(); ++index )
689 argv[index] = argvstr[index].c_str();
693 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
696 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
699 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
702 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf", {
"" }, {
"loopPause" }, {
"2500" } );
705 app.setPowerMgtEnabled(
true );
707 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
709 REQUIRE( app.stateAlert() ==
false );
710 REQUIRE( app.configOnly() ==
false );
711 REQUIRE( app.loopPause() == 2500 );
712 REQUIRE( app.powerDevice() ==
"" );
713 REQUIRE( app.powerChannel() ==
"" );
714 REQUIRE( app.powerElement() ==
"state" );
715 REQUIRE( app.powerTargetElement() ==
"target" );
716 REQUIRE( app.powerOnWait() == 0 );
718 REQUIRE( app.doHelp() ==
true );
719 REQUIRE( app.shutdown() ==
true );
722 SECTION(
"load a full config w unused config options" )
724 std::vector<const char *> argv;
725 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp",
"--config.validate" } );
727 argv.resize( argvstr.size() + 1, NULL );
728 for(
size_t index = 0; index < argvstr.size(); ++index )
730 argv[index] = argvstr[index].c_str();
734 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
737 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
740 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
744 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
745 {
"",
"power",
"power",
"power",
"power",
"power" },
746 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
747 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500000" } );
750 app.setPowerMgtEnabled(
true );
752 app.addUnusedConfig();
754 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
756 REQUIRE( app.stateAlert() ==
true );
757 REQUIRE( app.configOnly() ==
true );
758 REQUIRE( app.loopPause() == 2500 );
759 REQUIRE( app.powerDevice() ==
"pdu9" );
760 REQUIRE( app.powerChannel() ==
"thisch" );
761 REQUIRE( app.powerElement() ==
"thisel" );
762 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
763 REQUIRE( app.powerOnWait() == 0 );
765 REQUIRE( app.doHelp() ==
false );
766 REQUIRE( app.shutdown() ==
false );
776 SECTION(
"Basic PID Lock" )
778 std::vector<const char *> argv;
779 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
781 argv.resize( argvstr.size() + 1, NULL );
782 for(
size_t index = 0; index < argvstr.size(); ++index )
784 argv[index] = argvstr[index].c_str();
788 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
791 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/" );
794 std::filesystem::remove_all(
"/tmp/MagAOXApp_test/sys/testapp" );
798 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
800 REQUIRE( !std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
804 REQUIRE( std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
808 REQUIRE( !std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
811 SECTION(
"PID Lock, app directory creation error" )
813 std::vector<const char *> argv;
814 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
816 argv.resize( argvstr.size() + 1, NULL );
817 for(
size_t index = 0; index < argvstr.size(); ++index )
819 argv[index] = argvstr[index].c_str();
823 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
827 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
831 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
840 SECTION(
"Stale lock" )
842 std::vector<const char *> argv;
843 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
845 argv.resize( argvstr.size() + 1, NULL );
846 for(
size_t index = 0; index < argvstr.size(); ++index )
848 argv[index] = argvstr[index].c_str();
852 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
855 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
858 fout.open(
"/tmp/MagAOXApp_test/sys/testapp/pid" );
864 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
868 REQUIRE( std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
872 REQUIRE( !std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
875 SECTION(
"already locked" )
877 std::vector<const char *> argv;
878 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
880 argv.resize( argvstr.size() + 1, NULL );
881 for(
size_t index = 0; index < argvstr.size(); ++index )
883 argv[index] = argvstr[index].c_str();
887 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
890 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
893 fout.open(
"/tmp/MagAOXApp_test/sys/testapp/pid" );
897 XWCTEST_MAGAOXAPP_PID_LOCKED_ns::MagAOXApp_test app;
898 app.invokedName() = argv[0];
899 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
901 int rv = app.lockPID();
905 SECTION(
"write fails" )
907 std::vector<const char *> argv;
908 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
910 argv.resize( argvstr.size() + 1, NULL );
911 for(
size_t index = 0; index < argvstr.size(); ++index )
913 argv[index] = argvstr[index].c_str();
917 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
920 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
923 fout.open(
"/tmp/MagAOXApp_test/sys/testapp/pid" );
927 XWCTEST_MAGAOXAPP_PID_WRITE_FAIL_ns::MagAOXApp_test app;
928 app.invokedName() = argv[0];
929 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
931 int rv = app.lockPID();
1015TEST_CASE(
"INDI preperty creation utilities",
"[app::MagAOXApp]" )
1017 SECTION(
"createStandardIndiText" )
1022 pcf::IndiProperty ip;
1024 app.createStandardIndiText( ip,
"tprop",
"tlabel",
"tgroup" );
1026 REQUIRE( ip.getType() == pcf::IndiProperty::Text );
1027 REQUIRE( ip.getDevice() ==
"test" );
1028 REQUIRE( ip.getName() ==
"tprop" );
1029 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1030 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1031 REQUIRE( ip.find(
"current" ) ==
true );
1032 REQUIRE( ip.find(
"target" ) ==
true );
1033 REQUIRE( ip.getLabel() ==
"tlabel" );
1034 REQUIRE( ip.getGroup() ==
"tgroup" );
1037 SECTION(
"createROIndiText" )
1042 pcf::IndiProperty ip;
1044 app.createROIndiText( ip,
"tprop",
"tel",
"tlabel",
"tgroup",
"ellabel" );
1046 REQUIRE( ip.getType() == pcf::IndiProperty::Text );
1047 REQUIRE( ip.getDevice() ==
"test" );
1048 REQUIRE( ip.getName() ==
"tprop" );
1049 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadOnly );
1050 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1051 REQUIRE( ip.getLabel() ==
"tlabel" );
1052 REQUIRE( ip.getGroup() ==
"tgroup" );
1054 REQUIRE( ip.find(
"tel" ) ==
true );
1055 REQUIRE( ip[
"tel"].getLabel() ==
"ellabel" );
1058 SECTION(
"createStandardIndiNumber" )
1063 pcf::IndiProperty ip;
1065 app.createStandardIndiNumber<
double>( ip,
"tprop", 0.001, 1, 0.002,
"%0.23g",
"tlabel",
"tgroup" );
1067 REQUIRE( ip.getType() == pcf::IndiProperty::Number );
1068 REQUIRE( ip.getDevice() ==
"test" );
1069 REQUIRE( ip.getName() ==
"tprop" );
1070 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1071 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1073 REQUIRE( ip.find(
"current" ) ==
true );
1074 REQUIRE( ip[
"current"].getMin() ==
"0.001" );
1075 REQUIRE( ip[
"current"].getMax() ==
"1" );
1076 REQUIRE( ip[
"current"].getStep() ==
"0.002" );
1077 REQUIRE( ip[
"current"].getFormat() ==
"%0.23g" );
1079 REQUIRE( ip.find(
"target" ) ==
true );
1080 REQUIRE( ip[
"target"].getMin() ==
"0.001" );
1081 REQUIRE( ip[
"target"].getMax() ==
"1" );
1082 REQUIRE( ip[
"target"].getStep() ==
"0.002" );
1083 REQUIRE( ip[
"target"].getFormat() ==
"%0.23g" );
1085 REQUIRE( ip.getLabel() ==
"tlabel" );
1086 REQUIRE( ip.getGroup() ==
"tgroup" );
1089 SECTION(
"createROIndiNumber" )
1094 pcf::IndiProperty ip;
1096 app.createROIndiNumber( ip,
"tprop",
"tlabel",
"tgroup" );
1098 REQUIRE( ip.getType() == pcf::IndiProperty::Number );
1099 REQUIRE( ip.getDevice() ==
"test" );
1100 REQUIRE( ip.getName() ==
"tprop" );
1101 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadOnly );
1102 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1103 REQUIRE( ip.getLabel() ==
"tlabel" );
1104 REQUIRE( ip.getGroup() ==
"tgroup" );
1107 SECTION(
"createStandardIndiToggleSw" )
1112 pcf::IndiProperty ip;
1114 app.createStandardIndiToggleSw( ip,
"tpropz",
"tlabelz",
"tgroupz" );
1116 REQUIRE( ip.getType() == pcf::IndiProperty::Switch );
1117 REQUIRE( ip.getDevice() ==
"testz" );
1118 REQUIRE( ip.getName() ==
"tpropz" );
1119 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1120 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1121 REQUIRE( ip.getRule() == pcf::IndiProperty::AtMostOne );
1123 REQUIRE( ip.getNumElements() == 1 );
1124 REQUIRE( ip.find(
"toggle" ) ==
true );
1125 REQUIRE( ip[
"toggle"].getSwitchState() == pcf::IndiElement::Off );
1126 REQUIRE( ip.getLabel() ==
"tlabelz" );
1127 REQUIRE( ip.getGroup() ==
"tgroupz" );
1130 SECTION(
"createStandardIndiRequestSw" )
1135 pcf::IndiProperty ip;
1137 app.createStandardIndiRequestSw( ip,
"tpropz",
"tlabelz",
"tgroupz" );
1139 REQUIRE( ip.getType() == pcf::IndiProperty::Switch );
1140 REQUIRE( ip.getDevice() ==
"testz" );
1141 REQUIRE( ip.getName() ==
"tpropz" );
1142 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1143 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1144 REQUIRE( ip.getRule() == pcf::IndiProperty::AtMostOne );
1146 REQUIRE( ip.getNumElements() == 1 );
1147 REQUIRE( ip.find(
"request" ) ==
true );
1148 REQUIRE( ip[
"request"].getSwitchState() == pcf::IndiElement::Off );
1149 REQUIRE( ip.getLabel() ==
"tlabelz" );
1150 REQUIRE( ip.getGroup() ==
"tgroupz" );
1153 SECTION(
"createStandardIndiSelectionSw, w/ labels" )
1158 pcf::IndiProperty ip;
1160 std::vector<std::string> els( {
"el1",
"el2",
"el3" } );
1161 std::vector<std::string> labs( {
"l1",
"",
"l3" } );
1163 app.createStandardIndiSelectionSw( ip,
"tpropy", els, labs,
"tlabely",
"tgroupy" );
1165 REQUIRE( ip.getType() == pcf::IndiProperty::Switch );
1166 REQUIRE( ip.getDevice() ==
"testy" );
1167 REQUIRE( ip.getName() ==
"tpropy" );
1168 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1169 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1170 REQUIRE( ip.getRule() == pcf::IndiProperty::OneOfMany );
1172 REQUIRE( ip.getNumElements() == 3 );
1173 REQUIRE( ip.find(
"el1" ) ==
true );
1174 REQUIRE( ip[
"el1"].getSwitchState() == pcf::IndiElement::Off );
1175 REQUIRE( ip[
"el1"].getLabel() ==
"l1" );
1177 REQUIRE( ip.find(
"el2" ) ==
true );
1178 REQUIRE( ip[
"el2"].getSwitchState() == pcf::IndiElement::Off );
1179 REQUIRE( ip[
"el2"].getLabel() ==
"" );
1181 REQUIRE( ip.find(
"el3" ) ==
true );
1182 REQUIRE( ip[
"el3"].getSwitchState() == pcf::IndiElement::Off );
1183 REQUIRE( ip[
"el3"].getLabel() ==
"l3" );
1185 REQUIRE( ip.getLabel() ==
"tlabely" );
1186 REQUIRE( ip.getGroup() ==
"tgroupy" );
1189 SECTION(
"createStandardIndiSelectionSw, no labels" )
1194 pcf::IndiProperty ip;
1196 std::vector<std::string> els( {
"el1",
"el2",
"el3" } );
1198 app.createStandardIndiSelectionSw( ip,
"tpropy", els,
"tlabely",
"tgroupy" );
1200 REQUIRE( ip.getType() == pcf::IndiProperty::Switch );
1201 REQUIRE( ip.getDevice() ==
"testy" );
1202 REQUIRE( ip.getName() ==
"tpropy" );
1203 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1204 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1205 REQUIRE( ip.getRule() == pcf::IndiProperty::OneOfMany );
1207 REQUIRE( ip.getNumElements() == 3 );
1208 REQUIRE( ip.find(
"el1" ) ==
true );
1209 REQUIRE( ip[
"el1"].getSwitchState() == pcf::IndiElement::Off );
1210 REQUIRE( ip[
"el1"].getLabel() ==
"el1" );
1212 REQUIRE( ip.find(
"el2" ) ==
true );
1213 REQUIRE( ip[
"el2"].getSwitchState() == pcf::IndiElement::Off );
1214 REQUIRE( ip[
"el2"].getLabel() ==
"el2" );
1216 REQUIRE( ip.find(
"el3" ) ==
true );
1217 REQUIRE( ip[
"el3"].getSwitchState() == pcf::IndiElement::Off );
1218 REQUIRE( ip[
"el3"].getLabel() ==
"el3" );
1220 REQUIRE( ip.getLabel() ==
"tlabely" );
1221 REQUIRE( ip.getGroup() ==
"tgroupy" );