Project: engagement_recognition License: BSD Dependencies:
Used by:
None |
engagement_recognition/test/lib/engagement_params_test.cppGo to the documentation of this file.00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, Worcester Polytechnic Institute 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Worcester Polytechnic Institute. nor the names 00018 * of its contributors may be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 #include <gtest/gtest.h> 00035 #include <vector> 00036 #include <string> 00037 00038 #include "../src/recognition/lib/engagement_params.h" 00039 00043 TEST(EngagementParamsTestSuite, testNodeHandles) 00044 { 00045 // Create the node handles 00046 EngagementParams::createNodeHandles(); 00047 00048 // Make sure all of them exist 00049 EXPECT_TRUE(EngagementParams::getBaseHandle()); 00050 EXPECT_TRUE(EngagementParams::getCollabHandle()); 00051 EXPECT_TRUE(EngagementParams::getConfAdjacencyPairHandle()); 00052 EXPECT_TRUE(EngagementParams::getConfBackchannelHandle()); 00053 EXPECT_TRUE(EngagementParams::getConfDirGazeHandle()); 00054 EXPECT_TRUE(EngagementParams::getConfHandle()); 00055 EXPECT_TRUE(EngagementParams::getConfMFGazeHandle()); 00056 EXPECT_TRUE(EngagementParams::getPerformingHandle()); 00057 EXPECT_TRUE(EngagementParams::getInternalHandle()); 00058 EXPECT_TRUE(EngagementParams::getRecogHandle()); 00059 EXPECT_TRUE(EngagementParams::getRecogHumanHandle()); 00060 EXPECT_TRUE(EngagementParams::getRecogRobotHandle()); 00061 EXPECT_TRUE(EngagementParams::getVisionHandle()); 00062 00063 // Destroy the node handles 00064 EngagementParams::destroyNodeHandles(); 00065 00066 // Make sure none exist 00067 EXPECT_FALSE(EngagementParams::getBaseHandle()); 00068 EXPECT_FALSE(EngagementParams::getCollabHandle()); 00069 EXPECT_FALSE(EngagementParams::getConfAdjacencyPairHandle()); 00070 EXPECT_FALSE(EngagementParams::getConfBackchannelHandle()); 00071 EXPECT_FALSE(EngagementParams::getConfDirGazeHandle()); 00072 EXPECT_FALSE(EngagementParams::getConfHandle()); 00073 EXPECT_FALSE(EngagementParams::getConfMFGazeHandle()); 00074 EXPECT_FALSE(EngagementParams::getPerformingHandle()); 00075 EXPECT_FALSE(EngagementParams::getInternalHandle()); 00076 EXPECT_FALSE(EngagementParams::getRecogHandle()); 00077 EXPECT_FALSE(EngagementParams::getRecogHumanHandle()); 00078 EXPECT_FALSE(EngagementParams::getRecogRobotHandle()); 00079 EXPECT_FALSE(EngagementParams::getVisionHandle()); 00080 00081 // Destroy the node handles again 00082 EngagementParams::destroyNodeHandles(); 00083 00084 // Make sure none exist still 00085 EXPECT_FALSE(EngagementParams::getBaseHandle()); 00086 EXPECT_FALSE(EngagementParams::getCollabHandle()); 00087 EXPECT_FALSE(EngagementParams::getConfAdjacencyPairHandle()); 00088 EXPECT_FALSE(EngagementParams::getConfBackchannelHandle()); 00089 EXPECT_FALSE(EngagementParams::getConfDirGazeHandle()); 00090 EXPECT_FALSE(EngagementParams::getConfHandle()); 00091 EXPECT_FALSE(EngagementParams::getConfMFGazeHandle()); 00092 EXPECT_FALSE(EngagementParams::getPerformingHandle()); 00093 EXPECT_FALSE(EngagementParams::getInternalHandle()); 00094 EXPECT_FALSE(EngagementParams::getRecogHandle()); 00095 EXPECT_FALSE(EngagementParams::getRecogHumanHandle()); 00096 EXPECT_FALSE(EngagementParams::getRecogRobotHandle()); 00097 EXPECT_FALSE(EngagementParams::getVisionHandle()); 00098 00099 // Create the node handles 00100 EngagementParams::createNodeHandles(); 00101 00102 // Make sure all of them exist 00103 EXPECT_TRUE(EngagementParams::getBaseHandle()); 00104 EXPECT_TRUE(EngagementParams::getCollabHandle()); 00105 EXPECT_TRUE(EngagementParams::getConfAdjacencyPairHandle()); 00106 EXPECT_TRUE(EngagementParams::getConfBackchannelHandle()); 00107 EXPECT_TRUE(EngagementParams::getConfDirGazeHandle()); 00108 EXPECT_TRUE(EngagementParams::getConfHandle()); 00109 EXPECT_TRUE(EngagementParams::getConfMFGazeHandle()); 00110 EXPECT_TRUE(EngagementParams::getPerformingHandle()); 00111 EXPECT_TRUE(EngagementParams::getInternalHandle()); 00112 EXPECT_TRUE(EngagementParams::getRecogHandle()); 00113 EXPECT_TRUE(EngagementParams::getRecogHumanHandle()); 00114 EXPECT_TRUE(EngagementParams::getRecogRobotHandle()); 00115 EXPECT_TRUE(EngagementParams::getVisionHandle()); 00116 00117 // Create the node handles again 00118 EngagementParams::createNodeHandles(); 00119 00120 // Make sure all of them still exist 00121 EXPECT_TRUE(EngagementParams::getBaseHandle()); 00122 EXPECT_TRUE(EngagementParams::getCollabHandle()); 00123 EXPECT_TRUE(EngagementParams::getConfAdjacencyPairHandle()); 00124 EXPECT_TRUE(EngagementParams::getConfBackchannelHandle()); 00125 EXPECT_TRUE(EngagementParams::getConfDirGazeHandle()); 00126 EXPECT_TRUE(EngagementParams::getConfHandle()); 00127 EXPECT_TRUE(EngagementParams::getConfMFGazeHandle()); 00128 EXPECT_TRUE(EngagementParams::getPerformingHandle()); 00129 EXPECT_TRUE(EngagementParams::getInternalHandle()); 00130 EXPECT_TRUE(EngagementParams::getRecogHandle()); 00131 EXPECT_TRUE(EngagementParams::getRecogHumanHandle()); 00132 EXPECT_TRUE(EngagementParams::getRecogRobotHandle()); 00133 EXPECT_TRUE(EngagementParams::getVisionHandle()); 00134 } 00135 00139 TEST(EngagementParamsTestSuite, testBaseHandle) 00140 { 00141 EXPECT_TRUE(EngagementParams::getBaseHandle()); 00142 EXPECT_EQ("/",EngagementParams::getBaseHandle()->getNamespace()); 00143 } 00144 00148 TEST(EngagementParamsTestSuite, testCollabHandle) 00149 { 00150 EXPECT_TRUE(EngagementParams::getCollabHandle()); 00151 EXPECT_EQ("/" + engagement::COLLAB_NAMESPACE, 00152 EngagementParams::getCollabHandle()->getNamespace()); 00153 } 00154 00158 TEST(EngagementParamsTestSuite, testConfAPHandle) 00159 { 00160 EXPECT_TRUE(EngagementParams::getConfAdjacencyPairHandle()); 00161 EXPECT_EQ("/recognition_test/" + engagement::CONF_NAMESPACE + "/" + 00162 engagement::ADJACENCY_PAIR_NAMESPACE, 00163 EngagementParams::getConfAdjacencyPairHandle()->getNamespace()); 00164 } 00165 00169 TEST(EngagementParamsTestSuite, testConfBCHandle) 00170 { 00171 EXPECT_TRUE(EngagementParams::getConfBackchannelHandle()); 00172 EXPECT_EQ("/recognition_test/" + engagement::CONF_NAMESPACE + "/" + 00173 engagement::BACKCHANNEL_NAMESPACE, 00174 EngagementParams::getConfBackchannelHandle()->getNamespace()); 00175 } 00176 00180 TEST(EngagementParamsTestSuite, testConfDGHandle) 00181 { 00182 EXPECT_TRUE(EngagementParams::getConfDirGazeHandle()); 00183 EXPECT_EQ("/recognition_test/" + engagement::CONF_NAMESPACE + "/" + 00184 engagement::DIRECTED_GAZE_NAMESPACE, 00185 EngagementParams::getConfDirGazeHandle()->getNamespace()); 00186 } 00187 00191 TEST(EngagementParamsTestSuite, testConfHandle) 00192 { 00193 EXPECT_TRUE(EngagementParams::getConfHandle()); 00194 EXPECT_EQ("/recognition_test/" + engagement::CONF_NAMESPACE, 00195 EngagementParams::getConfHandle()->getNamespace()); 00196 } 00197 00201 TEST(EngagementParamsTestSuite, testConfMFGHandle) 00202 { 00203 EXPECT_TRUE(EngagementParams::getConfMFGazeHandle()); 00204 EXPECT_EQ("/recognition_test/" + engagement::CONF_NAMESPACE + "/" + 00205 engagement::MUTUAL_FACIAL_GAZE_NAMESPACE, 00206 EngagementParams::getConfMFGazeHandle()->getNamespace()); 00207 } 00208 00212 TEST(EngagementParamsTestSuite, testPerformingHandle) 00213 { 00214 EXPECT_TRUE(EngagementParams::getPerformingHandle()); 00215 EXPECT_EQ("/" + engagement::PERFORMING_NAMESPACE, 00216 EngagementParams::getPerformingHandle()->getNamespace()); 00217 } 00218 00222 TEST(EngagementParamsTestSuite, testInternalHandle) 00223 { 00224 EXPECT_TRUE(EngagementParams::getInternalHandle()); 00225 EXPECT_EQ("/recognition_test", 00226 EngagementParams::getInternalHandle()->getNamespace()); 00227 } 00228 00232 TEST(EngagementParamsTestSuite, testRecogHandle) 00233 { 00234 EXPECT_TRUE(EngagementParams::getRecogHandle()); 00235 EXPECT_EQ("/" + engagement::RECOGNITION_NAMESPACE, 00236 EngagementParams::getRecogHandle()->getNamespace()); 00237 } 00238 00242 TEST(EngagementParamsTestSuite, testRecogHumanHandle) 00243 { 00244 EXPECT_TRUE(EngagementParams::getRecogHumanHandle()); 00245 EXPECT_EQ("/" + engagement::RECOGNITION_NAMESPACE + "/" + 00246 engagement::HUMAN_NAMESPACE, 00247 EngagementParams::getRecogHumanHandle()->getNamespace()); 00248 } 00249 00253 TEST(EngagementParamsTestSuite, testRecogRobotHandle) 00254 { 00255 EXPECT_TRUE(EngagementParams::getRecogRobotHandle()); 00256 EXPECT_EQ("/" + engagement::RECOGNITION_NAMESPACE + "/" + 00257 engagement::ROBOT_NAMESPACE, 00258 EngagementParams::getRecogRobotHandle()->getNamespace()); 00259 } 00260 00264 TEST(EngagementParamsTestSuite, testVisionHandle) 00265 { 00266 EXPECT_TRUE(EngagementParams::getVisionHandle()); 00267 EXPECT_EQ("/" + engagement::VISION_NAMESPACE, 00268 EngagementParams::getVisionHandle()->getNamespace()); 00269 } 00270 00274 TEST(EngagementParamsTestSuite, testVerbosity) 00275 { 00276 // Default value of zero 00277 int original = 0; 00278 int verbosity = 0; 00279 00280 // Grab the conf node handle 00281 ros::NodeHandle *conf = EngagementParams::getConfHandle(); 00282 00283 // Load the verbosity from the param server 00284 if (conf) 00285 conf->param(engagement::VERBOSITY_PARAM, verbosity, 0); 00286 00287 // Force the params to reload the parameters 00288 EngagementParams::retrieveParameters(true); 00289 00290 original = verbosity; 00291 EXPECT_EQ(verbosity, EngagementParams::getVerbosity()); 00292 00293 // Set the parameter value to -100 as a test 00294 if (conf) 00295 { 00296 conf->setParam(engagement::VERBOSITY_PARAM, -100); 00297 conf->param(engagement::VERBOSITY_PARAM, verbosity, 0); 00298 } 00299 00300 // Force the params to reload the parameters 00301 EngagementParams::retrieveParameters(true); 00302 00303 EXPECT_EQ(verbosity, EngagementParams::getVerbosity()); 00304 00305 // Set the parameter value to 100 as a test 00306 if (conf) 00307 { 00308 conf->setParam(engagement::VERBOSITY_PARAM, 100); 00309 conf->param(engagement::VERBOSITY_PARAM, verbosity, 0); 00310 } 00311 00312 // Force the params to reload the parameters 00313 EngagementParams::retrieveParameters(true); 00314 00315 EXPECT_EQ(verbosity, EngagementParams::getVerbosity()); 00316 00317 // Reset the value to its original value 00318 if (conf) 00319 conf->setParam(engagement::VERBOSITY_PARAM, original); 00320 00321 // Force the params to reload the parameters 00322 EngagementParams::retrieveParameters(true); 00323 00324 EXPECT_EQ(original, EngagementParams::getVerbosity()); 00325 } 00326 00330 TEST(EngagementParamsTestSuite, testRecogTag) 00331 { 00332 // Default value of zero 00333 int original_fg = 31; 00334 int original_bg = 40; 00335 int fg_color = 31; 00336 int bg_color = 40; 00337 00338 // Store the parameter names and the prefix name 00339 std::string fg_color_param = engagement::RECOG_FG_COLOR_PARAM; 00340 std::string bg_color_param = engagement::RECOG_BG_COLOR_PARAM; 00341 std::string prefix = "[" + engagement::RECOGNITION_TYPE + "]:"; 00342 00343 // Grab the conf node handle 00344 ros::NodeHandle *conf = EngagementParams::getConfHandle(); 00345 00346 // Load the foreground and background colors from the param server 00347 if (conf) 00348 { 00349 conf->param(fg_color_param, fg_color, 31); 00350 conf->param(bg_color_param, bg_color, 40); 00351 } 00352 00353 // Force the params to reload the parameters 00354 EngagementParams::retrieveParameters(true); 00355 00356 // Store the original values 00357 original_fg = fg_color; 00358 original_bg = bg_color; 00359 00360 // Create the prefix string 00361 std::string result = "\033[" + 00362 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00363 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00364 00365 EXPECT_EQ(result, EngagementParams::getRecogTag()); 00366 00367 // Set the color values to a different value 00368 if (conf) 00369 { 00370 conf->setParam(fg_color_param, 90); 00371 conf->setParam(bg_color_param, 90); 00372 conf->param(fg_color_param, fg_color, 31); 00373 conf->param(bg_color_param, bg_color, 40); 00374 } 00375 00376 // Force the params to reload the parameters 00377 EngagementParams::retrieveParameters(true); 00378 00379 result = "\033[" + 00380 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00381 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00382 00383 EXPECT_EQ(result, EngagementParams::getRecogTag()); 00384 00385 // Reset the value to its original value 00386 if (conf) 00387 { 00388 conf->setParam(fg_color_param, original_fg); 00389 conf->setParam(bg_color_param, original_bg); 00390 conf->param(fg_color_param, fg_color, 31); 00391 conf->param(bg_color_param, bg_color, 40); 00392 } 00393 00394 // Force the params to reload the parameters 00395 EngagementParams::retrieveParameters(true); 00396 00397 result = "\033[" + 00398 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00399 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00400 00401 EXPECT_EQ(result, EngagementParams::getRecogTag()); 00402 } 00403 00407 TEST(EngagementParamsTestSuite, testAPTag) 00408 { 00409 // Default value of zero 00410 int original_fg = 31; 00411 int original_bg = 40; 00412 int fg_color = 31; 00413 int bg_color = 40; 00414 00415 // Store the parameter names and the prefix name 00416 std::string fg_color_param = engagement::ADJACENCY_PAIR_FG_COLOR_PARAM; 00417 std::string bg_color_param = engagement::ADJACENCY_PAIR_BG_COLOR_PARAM; 00418 std::string prefix = "[ " + engagement::ADJACENCY_PAIR_TYPE + "]:"; 00419 00420 // Grab the conf node handle 00421 ros::NodeHandle *conf = EngagementParams::getConfAdjacencyPairHandle(); 00422 00423 // Load the foreground and background colors from the param server 00424 if (conf) 00425 { 00426 conf->param(fg_color_param, fg_color, 31); 00427 conf->param(bg_color_param, bg_color, 40); 00428 } 00429 00430 // Force the params to reload the parameters 00431 EngagementParams::retrieveParameters(true); 00432 00433 // Store the original values 00434 original_fg = fg_color; 00435 original_bg = bg_color; 00436 00437 // Create the prefix string 00438 std::string result = "\033[" + 00439 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00440 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00441 00442 EXPECT_EQ(result, EngagementParams::getAPTag()); 00443 00444 // Set the color values to a different value 00445 if (conf) 00446 { 00447 conf->setParam(fg_color_param, 90); 00448 conf->setParam(bg_color_param, 90); 00449 conf->param(fg_color_param, fg_color, 31); 00450 conf->param(bg_color_param, bg_color, 40); 00451 } 00452 00453 // Force the params to reload the parameters 00454 EngagementParams::retrieveParameters(true); 00455 00456 result = "\033[" + 00457 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00458 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00459 00460 EXPECT_EQ(result, EngagementParams::getAPTag()); 00461 00462 // Reset the value to its original value 00463 if (conf) 00464 { 00465 conf->setParam(fg_color_param, original_fg); 00466 conf->setParam(bg_color_param, original_bg); 00467 conf->param(fg_color_param, fg_color, 31); 00468 conf->param(bg_color_param, bg_color, 40); 00469 } 00470 00471 // Force the params to reload the parameters 00472 EngagementParams::retrieveParameters(true); 00473 00474 result = "\033[" + 00475 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00476 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00477 00478 EXPECT_EQ(result, EngagementParams::getAPTag()); 00479 } 00480 00484 TEST(EngagementParamsTestSuite, testBCTag) 00485 { 00486 // Default value of zero 00487 int original_fg = 31; 00488 int original_bg = 40; 00489 int fg_color = 31; 00490 int bg_color = 40; 00491 00492 // Store the parameter names and the prefix name 00493 std::string fg_color_param = engagement::BACKCHANNEL_FG_COLOR_PARAM; 00494 std::string bg_color_param = engagement::BACKCHANNEL_BG_COLOR_PARAM; 00495 std::string prefix = "[ " + engagement::BACKCHANNEL_TYPE + "]:"; 00496 00497 // Grab the conf node handle 00498 ros::NodeHandle *conf = EngagementParams::getConfBackchannelHandle(); 00499 00500 // Load the foreground and background colors from the param server 00501 if (conf) 00502 { 00503 conf->param(fg_color_param, fg_color, 31); 00504 conf->param(bg_color_param, bg_color, 40); 00505 } 00506 00507 // Force the params to reload the parameters 00508 EngagementParams::retrieveParameters(true); 00509 00510 // Store the original values 00511 original_fg = fg_color; 00512 original_bg = bg_color; 00513 00514 // Create the prefix string 00515 std::string result = "\033[" + 00516 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00517 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00518 00519 EXPECT_EQ(result, EngagementParams::getBCTag()); 00520 00521 // Set the color values to a different value 00522 if (conf) 00523 { 00524 conf->setParam(fg_color_param, 90); 00525 conf->setParam(bg_color_param, 90); 00526 conf->param(fg_color_param, fg_color, 31); 00527 conf->param(bg_color_param, bg_color, 40); 00528 } 00529 00530 // Force the params to reload the parameters 00531 EngagementParams::retrieveParameters(true); 00532 00533 result = "\033[" + 00534 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00535 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00536 00537 EXPECT_EQ(result, EngagementParams::getBCTag()); 00538 00539 // Reset the value to its original value 00540 if (conf) 00541 { 00542 conf->setParam(fg_color_param, original_fg); 00543 conf->setParam(bg_color_param, original_bg); 00544 conf->param(fg_color_param, fg_color, 31); 00545 conf->param(bg_color_param, bg_color, 40); 00546 } 00547 00548 // Force the params to reload the parameters 00549 EngagementParams::retrieveParameters(true); 00550 00551 result = "\033[" + 00552 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00553 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00554 00555 EXPECT_EQ(result, EngagementParams::getBCTag()); 00556 } 00557 00561 TEST(EngagementParamsTestSuite, testDGTag) 00562 { 00563 // Default value of zero 00564 int original_fg = 31; 00565 int original_bg = 40; 00566 int fg_color = 31; 00567 int bg_color = 40; 00568 00569 // Test the red color 00570 int obj_fg_color = 31; 00571 std::string object = "red-plate"; 00572 std::string obj_pref = "[" + object + "]:"; 00573 00574 // Store the parameter names and the prefix name 00575 std::string fg_color_param = engagement::DIRECTED_GAZE_FG_COLOR_PARAM; 00576 std::string bg_color_param = engagement::DIRECTED_GAZE_BG_COLOR_PARAM; 00577 std::string prefix = "[ " + engagement::DIRECTED_GAZE_TYPE + "]:"; 00578 00579 // Grab the conf node handle 00580 ros::NodeHandle *conf = EngagementParams::getConfDirGazeHandle(); 00581 00582 // Load the foreground and background colors from the param server 00583 if (conf) 00584 { 00585 conf->param(fg_color_param, fg_color, 31); 00586 conf->param(bg_color_param, bg_color, 40); 00587 } 00588 00589 // Store the original values 00590 original_fg = fg_color; 00591 original_bg = bg_color; 00592 00593 // Create the prefix string 00594 std::string obj_result = "\033[" + 00595 boost::lexical_cast<std::string>(obj_fg_color) + "m" + obj_pref + 00596 "\033[0m "; 00597 00598 // Force the params to reload the parameters 00599 EngagementParams::retrieveParameters(true); 00600 00601 // Create the prefix string 00602 std::string result = "\033[" + 00603 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00604 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m " 00605 + obj_result; 00606 00607 const char *temp = EngagementParams::getDGTag(object); 00608 EXPECT_EQ(result, temp); 00609 00610 // Set the color values to a different value 00611 if (conf) 00612 { 00613 conf->setParam(fg_color_param, 90); 00614 conf->setParam(bg_color_param, 90); 00615 conf->param(fg_color_param, fg_color, 31); 00616 conf->param(bg_color_param, bg_color, 40); 00617 } 00618 00619 // Test the red color 00620 obj_fg_color = 31; 00621 object = "orange-plate"; 00622 obj_pref = "[" + object + "]:"; 00623 00624 // Create the prefix string 00625 obj_result = "\033[" + 00626 boost::lexical_cast<std::string>(obj_fg_color) + "m" + obj_pref + 00627 "\033[0m "; 00628 00629 // Force the params to reload the parameters 00630 EngagementParams::retrieveParameters(true); 00631 00632 result = "\033[" + 00633 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00634 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m " 00635 + obj_result; 00636 00637 temp = EngagementParams::getDGTag(object); 00638 EXPECT_EQ(result, temp); 00639 00640 // Reset the value to its original value 00641 if (conf) 00642 { 00643 conf->setParam(fg_color_param, original_fg); 00644 conf->setParam(bg_color_param, original_bg); 00645 conf->param(fg_color_param, fg_color, 31); 00646 conf->param(bg_color_param, bg_color, 40); 00647 } 00648 00649 // Test the green color 00650 obj_fg_color = 32; 00651 object = "green"; 00652 obj_pref = "[" + object + "]:"; 00653 00654 // Create the prefix string 00655 obj_result = "\033[" + 00656 boost::lexical_cast<std::string>(obj_fg_color) + "m" + obj_pref + 00657 "\033[0m "; 00658 00659 // Force the params to reload the parameters 00660 EngagementParams::retrieveParameters(true); 00661 00662 result = "\033[" + 00663 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00664 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m " 00665 + obj_result; 00666 00667 EXPECT_EQ(result, EngagementParams::getDGTag(object)); 00668 00669 // Test the yellow color 00670 obj_fg_color = 33; 00671 object = "yellow-organ"; 00672 obj_pref = "[" + object + "]:"; 00673 00674 // Create the prefix string 00675 obj_result = "\033[" + 00676 boost::lexical_cast<std::string>(obj_fg_color) + "m" + obj_pref + 00677 "\033[0m "; 00678 00679 result = "\033[" + 00680 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00681 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m " 00682 + obj_result; 00683 00684 EXPECT_EQ(result, EngagementParams::getDGTag(object)); 00685 00686 // Test the blue color 00687 obj_fg_color = 34; 00688 object = "blue-fsad89ag890gasijg"; 00689 obj_pref = "[" + object + "]:"; 00690 00691 // Create the prefix string 00692 obj_result = "\033[" + 00693 boost::lexical_cast<std::string>(obj_fg_color) + "m" + obj_pref + 00694 "\033[0m "; 00695 00696 result = "\033[" + 00697 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00698 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m " 00699 + obj_result; 00700 00701 EXPECT_EQ(result, EngagementParams::getDGTag(object)); 00702 00703 // Test the purple color 00704 obj_fg_color = 35; 00705 object = "purple19120840174"; 00706 obj_pref = "[" + object + "]:"; 00707 00708 // Create the prefix string 00709 obj_result = "\033[" + 00710 boost::lexical_cast<std::string>(obj_fg_color) + "m" + obj_pref + 00711 "\033[0m "; 00712 00713 result = "\033[" + 00714 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00715 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m " 00716 + obj_result; 00717 00718 EXPECT_EQ(result, EngagementParams::getDGTag(object)); 00719 00720 // Test the cyan color 00721 obj_fg_color = 36; 00722 object = "cyangown"; 00723 obj_pref = "[" + object + "]:"; 00724 00725 // Create the prefix string 00726 obj_result = "\033[" + 00727 boost::lexical_cast<std::string>(obj_fg_color) + "m" + obj_pref + 00728 "\033[0m "; 00729 00730 result = "\033[" + 00731 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00732 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m " 00733 + obj_result; 00734 00735 EXPECT_EQ(result, EngagementParams::getDGTag(object)); 00736 00737 // Test an invalid color 00738 obj_fg_color = 0; 00739 object = "speilberg"; 00740 obj_pref = "[" + object + "]:"; 00741 00742 // Create the prefix string 00743 obj_result = "\033[" + 00744 boost::lexical_cast<std::string>(obj_fg_color) + "m" + obj_pref + 00745 "\033[0m "; 00746 00747 result = "\033[" + 00748 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00749 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m " 00750 + obj_result; 00751 00752 EXPECT_EQ(result, EngagementParams::getDGTag(object)); 00753 00754 // Test an no object 00755 obj_fg_color = 0; 00756 object = ""; 00757 obj_pref = "[" + object + "]:"; 00758 00759 // Create the prefix string 00760 obj_result = ""; 00761 00762 result = "\033[" + 00763 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00764 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m " 00765 + obj_result; 00766 00767 EXPECT_EQ(result, EngagementParams::getDGTag(object)); 00768 00769 // Test an no object 00770 obj_fg_color = 0; 00771 object = " "; 00772 obj_pref = "[" + object + "]:"; 00773 00774 // Create the prefix string 00775 obj_result = "\033[" + 00776 boost::lexical_cast<std::string>(obj_fg_color) + "m" + obj_pref + 00777 "\033[0m "; 00778 00779 result = "\033[" + 00780 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00781 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m " 00782 + obj_result; 00783 00784 EXPECT_EQ(result, EngagementParams::getDGTag(object)); 00785 } 00786 00790 TEST(EngagementParamsTestSuite, testMFGTag) 00791 { 00792 // Default value of zero 00793 int original_fg = 31; 00794 int original_bg = 40; 00795 int fg_color = 31; 00796 int bg_color = 40; 00797 00798 // Store the parameter names and the prefix name 00799 std::string fg_color_param = engagement::MUTUAL_FACIAL_GAZE_FG_COLOR_PARAM; 00800 std::string bg_color_param = engagement::MUTUAL_FACIAL_GAZE_BG_COLOR_PARAM; 00801 std::string prefix = "[" + engagement::MUTUAL_FACIAL_GAZE_TYPE + "]:"; 00802 00803 // Grab the conf node handle 00804 ros::NodeHandle *conf = EngagementParams::getConfMFGazeHandle(); 00805 00806 // Load the foreground and background colors from the param server 00807 if (conf) 00808 { 00809 conf->param(fg_color_param, fg_color, 31); 00810 conf->param(bg_color_param, bg_color, 40); 00811 } 00812 00813 // Force the params to reload the parameters 00814 EngagementParams::retrieveParameters(true); 00815 00816 // Store the original values 00817 original_fg = fg_color; 00818 original_bg = bg_color; 00819 00820 // Create the prefix string 00821 std::string result = "\033[" + 00822 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00823 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00824 00825 EXPECT_EQ(result, EngagementParams::getMFGTag()); 00826 00827 // Set the color values to a different value 00828 if (conf) 00829 { 00830 conf->setParam(fg_color_param, 90); 00831 conf->setParam(bg_color_param, 90); 00832 conf->param(fg_color_param, fg_color, 31); 00833 conf->param(bg_color_param, bg_color, 40); 00834 } 00835 00836 // Force the params to reload the parameters 00837 EngagementParams::retrieveParameters(true); 00838 00839 result = "\033[" + 00840 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00841 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00842 00843 EXPECT_EQ(result, EngagementParams::getMFGTag()); 00844 00845 // Reset the value to its original value 00846 if (conf) 00847 { 00848 conf->setParam(fg_color_param, original_fg); 00849 conf->setParam(bg_color_param, original_bg); 00850 conf->param(fg_color_param, fg_color, 31); 00851 conf->param(bg_color_param, bg_color, 40); 00852 } 00853 00854 // Force the params to reload the parameters 00855 EngagementParams::retrieveParameters(true); 00856 00857 result = "\033[" + 00858 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00859 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00860 00861 EXPECT_EQ(result, EngagementParams::getMFGTag()); 00862 } 00863 00867 TEST(EngagementParamsTestSuite, testActorTag) 00868 { 00869 // Default value of zero 00870 int original_fg = 31; 00871 int original_bg = 40; 00872 int fg_color = 31; 00873 int bg_color = 40; 00874 00875 std::string actor = "face0"; 00876 00877 // Store the parameter names and the prefix name 00878 std::string fg_color_param = engagement::ACTOR_FG_COLOR_PARAM; 00879 std::string bg_color_param = engagement::ACTOR_BG_COLOR_PARAM; 00880 std::string prefix = "[" + actor + "]:"; 00881 00882 // Grab the conf node handle 00883 ros::NodeHandle *conf = EngagementParams::getConfHandle(); 00884 00885 // Load the foreground and background colors from the param server 00886 if (conf) 00887 { 00888 conf->param(fg_color_param, fg_color, 31); 00889 conf->param(bg_color_param, bg_color, 40); 00890 } 00891 00892 // Force the params to reload the parameters 00893 EngagementParams::retrieveParameters(true); 00894 00895 // Store the original values 00896 original_fg = fg_color; 00897 original_bg = bg_color; 00898 00899 // Create the prefix string 00900 std::string result = "\033[" + 00901 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00902 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00903 00904 EXPECT_EQ(result, EngagementParams::getActorTag(actor)); 00905 00906 // Set the color values to a different value 00907 if (conf) 00908 { 00909 conf->setParam(fg_color_param, 90); 00910 conf->setParam(bg_color_param, 90); 00911 conf->param(fg_color_param, fg_color, 31); 00912 conf->param(bg_color_param, bg_color, 40); 00913 } 00914 00915 // Force the params to reload the parameters 00916 EngagementParams::retrieveParameters(true); 00917 00918 actor = engagement::ROBOT_TYPE; 00919 prefix = "[" + actor + "]:"; 00920 00921 result = "\033[" + 00922 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00923 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00924 00925 EXPECT_EQ(result, EngagementParams::getActorTag(actor)); 00926 00927 // Reset the value to its original value 00928 if (conf) 00929 { 00930 conf->setParam(fg_color_param, original_fg); 00931 conf->setParam(bg_color_param, original_bg); 00932 conf->param(fg_color_param, fg_color, 31); 00933 conf->param(bg_color_param, bg_color, 40); 00934 } 00935 00936 // Force the params to reload the parameters 00937 EngagementParams::retrieveParameters(true); 00938 00939 actor = "elephant"; 00940 prefix = "[" + actor + "]:"; 00941 00942 result = "\033[" + 00943 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00944 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00945 00946 EXPECT_EQ(result, EngagementParams::getActorTag(actor)); 00947 00948 actor = ""; 00949 prefix = "[" + actor + "]:"; 00950 00951 result = "\033[" + 00952 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00953 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00954 00955 EXPECT_EQ(result, EngagementParams::getActorTag(actor)); 00956 } 00957 00961 TEST(EngagementParamsTestSuite, testSemaphoreTag) 00962 { 00963 // Default value of zero 00964 int original_fg = 31; 00965 int original_bg = 40; 00966 int fg_color = 31; 00967 int bg_color = 40; 00968 00969 // Store the parameter names and the prefix name 00970 std::string fg_color_param = engagement::SEMAPHORE_FG_COLOR_PARAM; 00971 std::string bg_color_param = engagement::SEMAPHORE_BG_COLOR_PARAM; 00972 std::string prefix = "[" + engagement::SEMAPHORE_TYPE + "]:"; 00973 00974 // Grab the conf node handle 00975 ros::NodeHandle *conf = EngagementParams::getConfHandle(); 00976 00977 // Load the foreground and background colors from the param server 00978 if (conf) 00979 { 00980 conf->param(fg_color_param, fg_color, 31); 00981 conf->param(bg_color_param, bg_color, 40); 00982 } 00983 00984 // Force the params to reload the parameters 00985 EngagementParams::retrieveParameters(true); 00986 00987 // Store the original values 00988 original_fg = fg_color; 00989 original_bg = bg_color; 00990 00991 // Create the prefix string 00992 std::string result = "\033[" + 00993 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 00994 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 00995 00996 EXPECT_EQ(result, EngagementParams::getSemaphoreTag()); 00997 00998 // Set the color values to a different value 00999 if (conf) 01000 { 01001 conf->setParam(fg_color_param, 90); 01002 conf->setParam(bg_color_param, 90); 01003 conf->param(fg_color_param, fg_color, 31); 01004 conf->param(bg_color_param, bg_color, 40); 01005 } 01006 01007 // Force the params to reload the parameters 01008 EngagementParams::retrieveParameters(true); 01009 01010 result = "\033[" + 01011 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 01012 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 01013 01014 EXPECT_EQ(result, EngagementParams::getSemaphoreTag()); 01015 01016 // Reset the value to its original value 01017 if (conf) 01018 { 01019 conf->setParam(fg_color_param, original_fg); 01020 conf->setParam(bg_color_param, original_bg); 01021 conf->param(fg_color_param, fg_color, 31); 01022 conf->param(bg_color_param, bg_color, 40); 01023 } 01024 01025 // Force the params to reload the parameters 01026 EngagementParams::retrieveParameters(true); 01027 01028 result = "\033[" + 01029 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 01030 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 01031 01032 EXPECT_EQ(result, EngagementParams::getSemaphoreTag()); 01033 } 01034 01038 TEST(EngagementParamsTestSuite, testStateTag) 01039 { 01040 // Default value of zero 01041 int original_fg = 31; 01042 int original_bg = 40; 01043 int fg_color = 31; 01044 int bg_color = 40; 01045 01046 std::string state_name = "dg_start"; 01047 01048 // Store the parameter names and the prefix name 01049 std::string fg_color_param = engagement::STATE_FG_COLOR_PARAM; 01050 std::string bg_color_param = engagement::STATE_BG_COLOR_PARAM; 01051 std::string prefix = "[" + state_name + "]:"; 01052 01053 // Grab the conf node handle 01054 ros::NodeHandle *conf = EngagementParams::getConfHandle(); 01055 01056 // Load the foreground and background colors from the param server 01057 if (conf) 01058 { 01059 conf->param(fg_color_param, fg_color, 31); 01060 conf->param(bg_color_param, bg_color, 40); 01061 } 01062 01063 // Force the params to reload the parameters 01064 EngagementParams::retrieveParameters(true); 01065 01066 // Store the original values 01067 original_fg = fg_color; 01068 original_bg = bg_color; 01069 01070 // Create the prefix string 01071 std::string result = "\033[" + 01072 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 01073 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 01074 01075 EXPECT_EQ(result, EngagementParams::getStateTag(state_name)); 01076 01077 // Set the color values to a different value 01078 if (conf) 01079 { 01080 conf->setParam(fg_color_param, 90); 01081 conf->setParam(bg_color_param, 90); 01082 conf->param(fg_color_param, fg_color, 31); 01083 conf->param(bg_color_param, bg_color, 40); 01084 } 01085 01086 // Force the params to reload the parameters 01087 EngagementParams::retrieveParameters(true); 01088 01089 state_name = "AlIgAtOr"; 01090 prefix = "[" + state_name + "]:"; 01091 01092 result = "\033[" + 01093 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 01094 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 01095 01096 EXPECT_EQ(result, EngagementParams::getStateTag(state_name)); 01097 01098 // Reset the value to its original value 01099 if (conf) 01100 { 01101 conf->setParam(fg_color_param, original_fg); 01102 conf->setParam(bg_color_param, original_bg); 01103 conf->param(fg_color_param, fg_color, 31); 01104 conf->param(bg_color_param, bg_color, 40); 01105 } 01106 01107 // Force the params to reload the parameters 01108 EngagementParams::retrieveParameters(true); 01109 01110 result = "\033[" + 01111 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 01112 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 01113 01114 EXPECT_EQ(result, EngagementParams::getStateTag(state_name)); 01115 01116 state_name = ""; 01117 prefix = "[" + state_name + "]:"; 01118 01119 result = "\033[" + 01120 boost::lexical_cast<std::string>(fg_color) + "m\033[" + 01121 boost::lexical_cast<std::string>(bg_color) + "m" + prefix + "\033[0m "; 01122 01123 EXPECT_EQ(result, EngagementParams::getStateTag(state_name)); 01124 } 01125 01129 TEST(EngagementParamsTestSuite, testRedObjectTag) 01130 { 01131 // Test the red color 01132 int fg_color = 31; 01133 std::string object = "red-plate"; 01134 std::string prefix = "[" + object + "]:"; 01135 01136 // Create the prefix string 01137 std::string result = "\033[" + 01138 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01139 01140 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01141 01142 // Test the color 01143 object = "RED-UMBRELLA"; 01144 prefix = "[" + object + "]:"; 01145 01146 // Create the prefix string 01147 result = "\033[" + 01148 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01149 01150 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01151 01152 // Test the color 01153 object = "rEd-uMbrElLlaaaa"; 01154 prefix = "[" + object + "]:"; 01155 01156 // Create the prefix string 01157 result = "\033[" + 01158 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01159 01160 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01161 } 01162 01166 TEST(EngagementParamsTestSuite, testOrangeObjectTag) 01167 { 01168 // Test the orange color 01169 int fg_color = 31; 01170 std::string object = "orange-bicycle"; 01171 std::string prefix = "[" + object + "]:"; 01172 01173 // Create the prefix string 01174 std::string result = "\033[" + 01175 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01176 01177 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01178 01179 // Test the color 01180 object = "ORANGE-PERSON"; 01181 prefix = "[" + object + "]:"; 01182 01183 // Create the prefix string 01184 result = "\033[" + 01185 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01186 01187 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01188 01189 // Test the color 01190 object = "oRaNGE * ^ % $ #af"; 01191 prefix = "[" + object + "]:"; 01192 01193 // Create the prefix string 01194 result = "\033[" + 01195 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01196 01197 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01198 } 01199 01203 TEST(EngagementParamsTestSuite, testGreenObjectTag) 01204 { 01205 // Test the green color 01206 int fg_color = 32; 01207 std::string object = "green"; 01208 std::string prefix = "[" + object + "]:"; 01209 01210 // Create the prefix string 01211 std::string result = "\033[" + 01212 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01213 01214 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01215 01216 // Test the color 01217 object = "GREEN_THING"; 01218 prefix = "[" + object + "]:"; 01219 01220 // Create the prefix string 01221 result = "\033[" + 01222 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01223 01224 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01225 01226 // Test the color 01227 object = "GReeN"; 01228 prefix = "[" + object + "]:"; 01229 01230 // Create the prefix string 01231 result = "\033[" + 01232 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01233 01234 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01235 } 01236 01240 TEST(EngagementParamsTestSuite, testYellowObjectTag) 01241 { 01242 // Test the yellow color 01243 int fg_color = 33; 01244 std::string object = "yellow-hair"; 01245 std::string prefix = "[" + object + "]:"; 01246 01247 // Create the prefix string 01248 std::string result = "\033[" + 01249 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01250 01251 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01252 01253 // Test the red color 01254 object = "YELLOW-123"; 01255 prefix = "[" + object + "]:"; 01256 01257 // Create the prefix string 01258 result = "\033[" + 01259 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01260 01261 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01262 01263 // Test the red color 01264 object = "YElLow-plaTE"; 01265 prefix = "[" + object + "]:"; 01266 01267 // Create the prefix string 01268 result = "\033[" + 01269 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01270 01271 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01272 } 01273 01277 TEST(EngagementParamsTestSuite, testBlueObjectTag) 01278 { 01279 // Test the blue color 01280 int fg_color = 34; 01281 std::string object = "blue-ice-princess"; 01282 std::string prefix = "[" + object + "]:"; 01283 01284 // Create the prefix string 01285 std::string result = "\033[" + 01286 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01287 01288 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01289 01290 // Test the red color 01291 object = "BLUE-SKY"; 01292 prefix = "[" + object + "]:"; 01293 01294 // Create the prefix string 01295 result = "\033[" + 01296 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01297 01298 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01299 01300 // Test the red color 01301 object = "bLuE plate"; 01302 prefix = "[" + object + "]:"; 01303 01304 // Create the prefix string 01305 result = "\033[" + 01306 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01307 01308 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01309 } 01310 01314 TEST(EngagementParamsTestSuite, testPurpleObjectTag) 01315 { 01316 // Test the purple color 01317 int fg_color = 35; 01318 std::string object = "purple-PANDA"; 01319 std::string prefix = "[" + object + "]:"; 01320 01321 // Create the prefix string 01322 std::string result = "\033[" + 01323 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01324 01325 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01326 01327 // Test the red color 01328 object = "PURPLE-PANTHERS"; 01329 prefix = "[" + object + "]:"; 01330 01331 // Create the prefix string 01332 result = "\033[" + 01333 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01334 01335 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01336 01337 // Test the red color 01338 object = "pURPle-penciL"; 01339 prefix = "[" + object + "]:"; 01340 01341 // Create the prefix string 01342 result = "\033[" + 01343 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01344 01345 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01346 } 01347 01351 TEST(EngagementParamsTestSuite, testCyanObjectTag) 01352 { 01353 // Test the cyan color 01354 int fg_color = 36; 01355 std::string object = "cyan-iguana-like-object"; 01356 std::string prefix = "[" + object + "]:"; 01357 01358 // Create the prefix string 01359 std::string result = "\033[" + 01360 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01361 01362 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01363 01364 // Test the red color 01365 object = "CYAN-ASTRONAUT"; 01366 prefix = "[" + object + "]:"; 01367 01368 // Create the prefix string 01369 result = "\033[" + 01370 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01371 01372 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01373 01374 // Test the red color 01375 object = "CyAn-space"; 01376 prefix = "[" + object + "]:"; 01377 01378 // Create the prefix string 01379 result = "\033[" + 01380 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01381 01382 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01383 } 01384 01388 TEST(EngagementParamsTestSuite, testUnknownObjectTag) 01389 { 01390 // Test an unknown color 01391 int fg_color = 0; 01392 std::string object = "rainbow-colored-dwarf"; 01393 std::string prefix = "[" + object + "]:"; 01394 01395 // Create the prefix string 01396 std::string result = "\033[" + 01397 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01398 01399 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01400 01401 // Test the red color 01402 object = "UNKNOWN_COLOR"; 01403 prefix = "[" + object + "]:"; 01404 01405 // Create the prefix string 01406 result = "\033[" + 01407 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01408 01409 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01410 01411 // Test the red color 01412 object = "uNkOwN-ObjEct"; 01413 prefix = "[" + object + "]:"; 01414 01415 // Create the prefix string 01416 result = "\033[" + 01417 boost::lexical_cast<std::string>(fg_color) + "m" + prefix + "\033[0m "; 01418 01419 EXPECT_EQ(result, EngagementParams::getObjectTag(object)); 01420 } |