123 SECTION(
"using default paths, configname is invoked name" )
125 std::vector<std::string> argvstr( {
"./execname" } );
127 std::vector<const char *> argv( argvstr.size() + 1, NULL );
128 for(
size_t index = 0; index < argvstr.size(); ++index )
130 argv[index] = argvstr[index].c_str();
137 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
155 REQUIRE( app.configBase() ==
"" );
157 REQUIRE( app.configName() ==
"execname" );
163 SECTION(
"using default paths, with config-ed name" )
165 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
167 std::vector<const char *> argv( argvstr.size() + 1, NULL );
168 for(
size_t index = 0; index < argvstr.size(); ++index )
170 argv[index] = argvstr[index].c_str();
176 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
187 REQUIRE( app.configBase() ==
"" );
189 REQUIRE( app.configName() ==
"testapp" );
196 SECTION(
"using environment paths, with config-ed name" )
198 std::vector<const char *> argv;
199 std::vector<std::string> argvstr( {
"./execname",
"--name",
"testapp2" } );
201 argv.resize( argvstr.size() + 1, NULL );
202 for(
size_t index = 0; index < argvstr.size(); ++index )
204 argv[index] = argvstr[index].c_str();
208 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
224 snprintf( syspath,
sizeof( syspath ),
"%s=sys2",
MAGAOX_env_sys );
227 char secretspath[1024];
229 putenv( secretspath );
232 snprintf( cpupath,
sizeof( cpupath ),
"%s=/tmp/MagAOX/cpuset",
MAGAOX_env_cpuset );
240 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
242 REQUIRE( app.basePath() ==
"/tmp/MagAOXApp_test" );
243 REQUIRE( app.configDir() == app.basePath() +
'/' +
"config2" );
245 REQUIRE( app.calibDir() == app.basePath() +
'/' +
"calib2" );
246 REQUIRE( app.m_log.logPath() == app.basePath() +
'/' +
"logs2" );
247 REQUIRE( app.sysPath() == app.basePath() +
'/' +
"sys2" );
248 REQUIRE( app.secretsPath() == app.basePath() +
'/' +
"secrets2" );
249 REQUIRE( app.cpusetPath() ==
"/tmp/MagAOX/cpuset" );
250 REQUIRE( app.configBase() ==
"cbase" );
252 REQUIRE( app.configName() ==
"testapp2" );
264 SECTION(
"setup basic config" )
269 app.setupBasicConfig();
271 REQUIRE( app.shutdown() ==
false );
274 SECTION(
"load basic config w all defaults w/out pwr management" )
279 app.setupBasicConfig();
281 app.loadBasicConfig();
285 REQUIRE( app.stateAlert() ==
false );
286 REQUIRE( app.gitAlert() ==
false );
287 REQUIRE( app.shutdown() ==
false );
290 SECTION(
"load basic config w all defaults w/out pwr management, setting state and clearing alerts" )
292 std::vector<const char *> argv;
293 std::vector<std::string> argvstr( {
"./execname",
"--name",
"testapp" } );
295 argv.resize( argvstr.size() + 1, NULL );
296 for(
size_t index = 0; index < argvstr.size(); ++index )
298 argv[index] = argvstr[index].c_str();
304 app.setupBasicConfig();
306 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
308 app.loadBasicConfig();
312 REQUIRE( app.stateAlert() ==
true );
313 REQUIRE( app.gitAlert() ==
true );
314 REQUIRE( app.shutdown() ==
false );
317 REQUIRE( app.stateAlert() ==
false );
318 REQUIRE( app.gitAlert() ==
true );
319 REQUIRE( app.shutdown() ==
false );
327 REQUIRE( app.stateLogged() == 0 );
328 REQUIRE( app.stateLogged() == 1 );
331 REQUIRE( app.stateAlert() ==
true );
334 REQUIRE( app.stateAlert() ==
false );
340 REQUIRE( app.stateAlert() ==
true );
343 REQUIRE( app.stateAlert() ==
false );
349 REQUIRE( app.stateAlert() ==
true );
352 REQUIRE( app.stateAlert() ==
false );
358 REQUIRE( app.stateAlert() ==
true );
361 REQUIRE( app.stateAlert() ==
false );
367 REQUIRE( app.stateAlert() ==
true );
370 REQUIRE( app.stateAlert() ==
false );
376 REQUIRE( app.stateAlert() ==
true );
379 REQUIRE( app.stateAlert() ==
false );
382 SECTION(
"load basic config w all defaults w unconfigured pwr management" )
387 app.setupBasicConfig();
389 app.loadBasicConfig();
391 REQUIRE( app.shutdown() ==
true );
395 REQUIRE( app.stateAlert() ==
false );
396 REQUIRE( app.gitAlert() ==
false );
397 REQUIRE( app.shutdown() ==
true );
400 SECTION(
"load a full config" )
402 std::vector<const char *> argv;
403 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp",
"--config.validate" } );
405 argv.resize( argvstr.size() + 1, NULL );
406 for(
size_t index = 0; index < argvstr.size(); ++index )
408 argv[index] = argvstr[index].c_str();
412 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
415 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
418 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
421 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
422 {
"",
"power",
"power",
"power",
"power",
"power" },
423 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
424 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500000" } );
427 app.setPowerMgtEnabled(
true );
429 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
431 REQUIRE( app.stateAlert() ==
true );
432 REQUIRE( app.configOnly() ==
true );
433 REQUIRE( app.loopPause() == 2500 );
434 REQUIRE( app.powerDevice() ==
"pdu9" );
435 REQUIRE( app.powerChannel() ==
"thisch" );
436 REQUIRE( app.powerElement() ==
"thisel" );
437 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
438 REQUIRE( app.powerOnWait() == 0 );
440 REQUIRE( app.shutdown() ==
false );
443 SECTION(
"load a full config w unknown config in file, do help" )
445 std::vector<const char *> argv;
446 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
448 argv.resize( argvstr.size() + 1, NULL );
449 for(
size_t index = 0; index < argvstr.size(); ++index )
451 argv[index] = argvstr[index].c_str();
455 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
458 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
461 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
465 mx::app::writeConfigFile(
466 "/tmp/MagAOXApp_test/config/testapp.conf",
467 {
"",
"power",
"power",
"power",
"power",
"power",
"" },
468 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait",
"unknown" },
469 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500",
"value" } );
472 app.setPowerMgtEnabled(
true );
474 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
476 REQUIRE( app.stateAlert() ==
false );
477 REQUIRE( app.configOnly() ==
false );
478 REQUIRE( app.loopPause() == 2500 );
479 REQUIRE( app.powerDevice() ==
"pdu9" );
480 REQUIRE( app.powerChannel() ==
"thisch" );
481 REQUIRE( app.powerElement() ==
"thisel" );
482 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
483 REQUIRE( app.powerOnWait() == 500 );
485 REQUIRE( app.doHelp() ==
true );
486 REQUIRE( app.shutdown() ==
true );
489 SECTION(
"load a full config w unknown config in file, validate" )
491 std::vector<const char *> argv;
492 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp",
"--config.validate" } );
494 argv.resize( argvstr.size() + 1, NULL );
495 for(
size_t index = 0; index < argvstr.size(); ++index )
497 argv[index] = argvstr[index].c_str();
501 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
504 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
507 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
511 mx::app::writeConfigFile(
512 "/tmp/MagAOXApp_test/config/testapp.conf",
513 {
"",
"power",
"power",
"power",
"power",
"power",
"" },
514 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait",
"unknown" },
515 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500000",
"value" } );
518 app.setPowerMgtEnabled(
true );
520 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
522 REQUIRE( app.stateAlert() ==
true );
523 REQUIRE( app.configOnly() ==
true );
524 REQUIRE( app.loopPause() == 2500 );
525 REQUIRE( app.powerDevice() ==
"pdu9" );
526 REQUIRE( app.powerChannel() ==
"thisch" );
527 REQUIRE( app.powerElement() ==
"thisel" );
528 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
529 REQUIRE( app.powerOnWait() == 0 );
531 REQUIRE( app.doHelp() ==
false );
532 REQUIRE( app.shutdown() ==
true );
535 SECTION(
"load a full config w non-option clopt" )
537 std::vector<const char *> argv;
538 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp",
"straylight" } );
540 argv.resize( argvstr.size() + 1, NULL );
541 for(
size_t index = 0; index < argvstr.size(); ++index )
543 argv[index] = argvstr[index].c_str();
547 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
550 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
553 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
556 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
557 {
"",
"power",
"power",
"power",
"power",
"power" },
558 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
559 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500000" } );
562 app.setPowerMgtEnabled(
true );
564 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
566 REQUIRE( app.stateAlert() ==
false );
567 REQUIRE( app.configOnly() ==
false );
568 REQUIRE( app.loopPause() == 2500 );
569 REQUIRE( app.powerDevice() ==
"pdu9" );
570 REQUIRE( app.powerChannel() ==
"thisch" );
571 REQUIRE( app.powerElement() ==
"thisel" );
572 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
573 REQUIRE( app.powerOnWait() == 0 );
575 REQUIRE( app.doHelp() ==
true );
576 REQUIRE( app.shutdown() ==
true );
579 SECTION(
"load a full config w no power mgt opts" )
581 std::vector<const char *> argv;
582 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
584 argv.resize( argvstr.size() + 1, NULL );
585 for(
size_t index = 0; index < argvstr.size(); ++index )
587 argv[index] = argvstr[index].c_str();
591 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
594 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
597 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
600 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf", {
"" }, {
"loopPause" }, {
"2500" } );
603 app.setPowerMgtEnabled(
true );
605 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
607 REQUIRE( app.stateAlert() ==
false );
608 REQUIRE( app.configOnly() ==
false );
609 REQUIRE( app.loopPause() == 2500 );
610 REQUIRE( app.powerDevice() ==
"" );
611 REQUIRE( app.powerChannel() ==
"" );
612 REQUIRE( app.powerElement() ==
"state" );
613 REQUIRE( app.powerTargetElement() ==
"target" );
614 REQUIRE( app.powerOnWait() == 0 );
616 REQUIRE( app.doHelp() ==
true );
617 REQUIRE( app.shutdown() ==
true );
620 SECTION(
"load a full config w unused config options" )
622 std::vector<const char *> argv;
623 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp",
"--config.validate" } );
625 argv.resize( argvstr.size() + 1, NULL );
626 for(
size_t index = 0; index < argvstr.size(); ++index )
628 argv[index] = argvstr[index].c_str();
632 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
635 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
638 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
642 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
643 {
"",
"power",
"power",
"power",
"power",
"power" },
644 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
645 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"500000" } );
648 app.setPowerMgtEnabled(
true );
650 app.addUnusedConfig();
652 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
654 REQUIRE( app.stateAlert() ==
true );
655 REQUIRE( app.configOnly() ==
true );
656 REQUIRE( app.loopPause() == 2500 );
657 REQUIRE( app.powerDevice() ==
"pdu9" );
658 REQUIRE( app.powerChannel() ==
"thisch" );
659 REQUIRE( app.powerElement() ==
"thisel" );
660 REQUIRE( app.powerTargetElement() ==
"thistgtel" );
661 REQUIRE( app.powerOnWait() == 0 );
663 REQUIRE( app.doHelp() ==
false );
664 REQUIRE( app.shutdown() ==
false );
676 std::vector<const char *> argv;
677 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
679 argv.resize( argvstr.size() + 1, NULL );
680 for(
size_t index = 0; index < argvstr.size(); ++index )
682 argv[index] = argvstr[index].c_str();
686 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
689 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/" );
692 std::filesystem::remove_all(
"/tmp/MagAOXApp_test/sys/testapp" );
696 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
698 REQUIRE( !std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
702 REQUIRE( std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
706 REQUIRE( !std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
709 SECTION(
"PID Lock, app directory creation erryr" )
711 std::vector<const char *> argv;
712 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
714 argv.resize( argvstr.size() + 1, NULL );
715 for(
size_t index = 0; index < argvstr.size(); ++index )
717 argv[index] = argvstr[index].c_str();
721 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
725 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
729 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
740 std::vector<const char *> argv;
741 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
743 argv.resize( argvstr.size() + 1, NULL );
744 for(
size_t index = 0; index < argvstr.size(); ++index )
746 argv[index] = argvstr[index].c_str();
750 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
753 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
756 fout.open(
"/tmp/MagAOXApp_test/sys/testapp/pid" );
762 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
766 REQUIRE( std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
770 REQUIRE( !std::filesystem::exists(
"/tmp/MagAOXApp_test/sys/testapp/pid" ) );
775 std::vector<const char *> argv;
776 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
778 argv.resize( argvstr.size() + 1, NULL );
779 for(
size_t index = 0; index < argvstr.size(); ++index )
781 argv[index] = argvstr[index].c_str();
785 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
788 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
791 fout.open(
"/tmp/MagAOXApp_test/sys/testapp/pid" );
795 XWCTEST_MAGAOXAPP_PID_LOCKED_ns::MagAOXApp_test app;
796 app.invokedName() = argv[0];
797 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
799 int rv = app.lockPID();
805 std::vector<const char *> argv;
806 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
808 argv.resize( argvstr.size() + 1, NULL );
809 for(
size_t index = 0; index < argvstr.size(); ++index )
811 argv[index] = argvstr[index].c_str();
815 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
818 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
821 fout.open(
"/tmp/MagAOXApp_test/sys/testapp/pid" );
825 XWCTEST_MAGAOXAPP_PID_WRITE_FAIL_ns::MagAOXApp_test app;
826 app.invokedName() = argv[0];
827 app.setDefaults( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
829 int rv = app.lockPID();
913TEST_CASE(
"INDI preperty creation utilities",
"[app::MagAOXApp]" )
915 SECTION(
"createStandardIndiText" )
920 pcf::IndiProperty ip;
922 app.createStandardIndiText( ip,
"tprop",
"tlabel",
"tgroup" );
924 REQUIRE( ip.getType() == pcf::IndiProperty::Text );
925 REQUIRE( ip.getDevice() ==
"test" );
926 REQUIRE( ip.getName() ==
"tprop" );
927 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
928 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
929 REQUIRE( ip.find(
"current" ) ==
true );
930 REQUIRE( ip.find(
"target" ) ==
true );
931 REQUIRE( ip.getLabel() ==
"tlabel" );
932 REQUIRE( ip.getGroup() ==
"tgroup" );
940 pcf::IndiProperty ip;
942 app.createROIndiText( ip,
"tprop",
"tel",
"tlabel",
"tgroup",
"ellabel" );
944 REQUIRE( ip.getType() == pcf::IndiProperty::Text );
945 REQUIRE( ip.getDevice() ==
"test" );
946 REQUIRE( ip.getName() ==
"tprop" );
947 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadOnly );
948 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
949 REQUIRE( ip.getLabel() ==
"tlabel" );
950 REQUIRE( ip.getGroup() ==
"tgroup" );
952 REQUIRE( ip.find(
"tel" ) ==
true );
953 REQUIRE( ip[
"tel"].getLabel() ==
"ellabel" );
956 SECTION(
"createStandardIndiNumber" )
961 pcf::IndiProperty ip;
963 app.createStandardIndiNumber<
double>( ip,
"tprop", 0.001, 1, 0.002,
"%0.23g",
"tlabel",
"tgroup" );
965 REQUIRE( ip.getType() == pcf::IndiProperty::Number );
966 REQUIRE( ip.getDevice() ==
"test" );
967 REQUIRE( ip.getName() ==
"tprop" );
968 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
969 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
971 REQUIRE( ip.find(
"current" ) ==
true );
972 REQUIRE( ip[
"current"].getMin() ==
"0.001" );
973 REQUIRE( ip[
"current"].getMax() ==
"1" );
974 REQUIRE( ip[
"current"].getStep() ==
"0.002" );
975 REQUIRE( ip[
"current"].getFormat() ==
"%0.23g" );
977 REQUIRE( ip.find(
"target" ) ==
true );
978 REQUIRE( ip[
"target"].getMin() ==
"0.001" );
979 REQUIRE( ip[
"target"].getMax() ==
"1" );
980 REQUIRE( ip[
"target"].getStep() ==
"0.002" );
981 REQUIRE( ip[
"target"].getFormat() ==
"%0.23g" );
983 REQUIRE( ip.getLabel() ==
"tlabel" );
984 REQUIRE( ip.getGroup() ==
"tgroup" );
987 SECTION(
"createROIndiNumber" )
992 pcf::IndiProperty ip;
994 app.createROIndiNumber( ip,
"tprop",
"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::ReadOnly );
1000 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1001 REQUIRE( ip.getLabel() ==
"tlabel" );
1002 REQUIRE( ip.getGroup() ==
"tgroup" );
1005 SECTION(
"createStandardIndiToggleSw" )
1010 pcf::IndiProperty ip;
1012 app.createStandardIndiToggleSw( ip,
"tpropz",
"tlabelz",
"tgroupz" );
1014 REQUIRE( ip.getType() == pcf::IndiProperty::Switch );
1015 REQUIRE( ip.getDevice() ==
"testz" );
1016 REQUIRE( ip.getName() ==
"tpropz" );
1017 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1018 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1019 REQUIRE( ip.getRule() == pcf::IndiProperty::AtMostOne );
1021 REQUIRE( ip.getNumElements() == 1 );
1022 REQUIRE( ip.find(
"toggle" ) ==
true );
1023 REQUIRE( ip[
"toggle"].getSwitchState() == pcf::IndiElement::Off );
1024 REQUIRE( ip.getLabel() ==
"tlabelz" );
1025 REQUIRE( ip.getGroup() ==
"tgroupz" );
1028 SECTION(
"createStandardIndiRequestSw" )
1033 pcf::IndiProperty ip;
1035 app.createStandardIndiRequestSw( ip,
"tpropz",
"tlabelz",
"tgroupz" );
1037 REQUIRE( ip.getType() == pcf::IndiProperty::Switch );
1038 REQUIRE( ip.getDevice() ==
"testz" );
1039 REQUIRE( ip.getName() ==
"tpropz" );
1040 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1041 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1042 REQUIRE( ip.getRule() == pcf::IndiProperty::AtMostOne );
1044 REQUIRE( ip.getNumElements() == 1 );
1045 REQUIRE( ip.find(
"request" ) ==
true );
1046 REQUIRE( ip[
"request"].getSwitchState() == pcf::IndiElement::Off );
1047 REQUIRE( ip.getLabel() ==
"tlabelz" );
1048 REQUIRE( ip.getGroup() ==
"tgroupz" );
1051 SECTION(
"createStandardIndiSelectionSw, w/ labels" )
1056 pcf::IndiProperty ip;
1058 std::vector<std::string> els( {
"el1",
"el2",
"el3" } );
1059 std::vector<std::string> labs( {
"l1",
"",
"l3" } );
1061 app.createStandardIndiSelectionSw( ip,
"tpropy", els, labs,
"tlabely",
"tgroupy" );
1063 REQUIRE( ip.getType() == pcf::IndiProperty::Switch );
1064 REQUIRE( ip.getDevice() ==
"testy" );
1065 REQUIRE( ip.getName() ==
"tpropy" );
1066 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1067 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1068 REQUIRE( ip.getRule() == pcf::IndiProperty::OneOfMany );
1070 REQUIRE( ip.getNumElements() == 3 );
1071 REQUIRE( ip.find(
"el1" ) ==
true );
1072 REQUIRE( ip[
"el1"].getSwitchState() == pcf::IndiElement::Off );
1073 REQUIRE( ip[
"el1"].getLabel() ==
"l1" );
1075 REQUIRE( ip.find(
"el2" ) ==
true );
1076 REQUIRE( ip[
"el2"].getSwitchState() == pcf::IndiElement::Off );
1077 REQUIRE( ip[
"el2"].getLabel() ==
"" );
1079 REQUIRE( ip.find(
"el3" ) ==
true );
1080 REQUIRE( ip[
"el3"].getSwitchState() == pcf::IndiElement::Off );
1081 REQUIRE( ip[
"el3"].getLabel() ==
"l3" );
1083 REQUIRE( ip.getLabel() ==
"tlabely" );
1084 REQUIRE( ip.getGroup() ==
"tgroupy" );
1087 SECTION(
"createStandardIndiSelectionSw, no labels" )
1092 pcf::IndiProperty ip;
1094 std::vector<std::string> els( {
"el1",
"el2",
"el3" } );
1096 app.createStandardIndiSelectionSw( ip,
"tpropy", els,
"tlabely",
"tgroupy" );
1098 REQUIRE( ip.getType() == pcf::IndiProperty::Switch );
1099 REQUIRE( ip.getDevice() ==
"testy" );
1100 REQUIRE( ip.getName() ==
"tpropy" );
1101 REQUIRE( ip.getPerm() == pcf::IndiProperty::ReadWrite );
1102 REQUIRE( ip.getState() == pcf::IndiProperty::Idle );
1103 REQUIRE( ip.getRule() == pcf::IndiProperty::OneOfMany );
1105 REQUIRE( ip.getNumElements() == 3 );
1106 REQUIRE( ip.find(
"el1" ) ==
true );
1107 REQUIRE( ip[
"el1"].getSwitchState() == pcf::IndiElement::Off );
1108 REQUIRE( ip[
"el1"].getLabel() ==
"el1" );
1110 REQUIRE( ip.find(
"el2" ) ==
true );
1111 REQUIRE( ip[
"el2"].getSwitchState() == pcf::IndiElement::Off );
1112 REQUIRE( ip[
"el2"].getLabel() ==
"el2" );
1114 REQUIRE( ip.find(
"el3" ) ==
true );
1115 REQUIRE( ip[
"el3"].getSwitchState() == pcf::IndiElement::Off );
1116 REQUIRE( ip[
"el3"].getLabel() ==
"el3" );
1118 REQUIRE( ip.getLabel() ==
"tlabely" );
1119 REQUIRE( ip.getGroup() ==
"tgroupy" );