Project: engagement_recognition License: BSD Dependencies:
Used by:
None |
engagement_recognition/test/actors/robot_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/actors/robot.h" 00039 00043 TEST(RobotTestSuite, testConstructor) 00044 { 00045 Robot robot = Robot(); 00046 00047 std::vector<std::string> objects; 00048 objects.push_back("blue-plate"); 00049 00050 EXPECT_FALSE(robot.isFacialGaze("face0")); 00051 EXPECT_FALSE(robot.isSpeaking()); 00052 EXPECT_FALSE(robot.isLooking(std::vector<std::string>(objects))); 00053 EXPECT_FALSE(robot.isPointing(std::vector<std::string>(objects))); 00054 EXPECT_FALSE(robot.isPointing(std::vector<std::string>(objects))); 00055 EXPECT_EQ((unsigned)0, robot.getLooking().size()); 00056 EXPECT_EQ((unsigned)0, robot.getPointing().size()); 00057 EXPECT_EQ((unsigned)0, robot.getPointing().size()); 00058 EXPECT_TRUE(robot.getLogger()); 00059 } 00060 00064 TEST(RobotTestSuite, testFacialGaze) 00065 { 00066 Robot robot = Robot(); 00067 std::string actor = "face0"; 00068 00069 EXPECT_FALSE(robot.isFacialGaze(actor)); 00070 robot.setFacialGaze(true, actor); 00071 EXPECT_TRUE(robot.isFacialGaze(actor)); 00072 robot.setFacialGaze(true, actor); 00073 EXPECT_TRUE(robot.isFacialGaze(actor)); 00074 robot.setFacialGaze(false, actor); 00075 EXPECT_FALSE(robot.isFacialGaze(actor)); 00076 robot.setFacialGaze(false, actor); 00077 EXPECT_FALSE(robot.isFacialGaze(actor)); 00078 robot.setFacialGaze(false, ""); 00079 EXPECT_FALSE(robot.isFacialGaze(actor)); 00080 robot.setFacialGaze(true, actor); 00081 EXPECT_TRUE(robot.isFacialGaze(actor)); 00082 robot.setFacialGaze(false, ""); 00083 EXPECT_FALSE(robot.isFacialGaze(actor)); 00084 } 00085 00089 TEST(RobotTestSuite, testSpeaking) 00090 { 00091 Robot robot = Robot(); 00092 00093 EXPECT_FALSE(robot.isSpeaking()); 00094 robot.setSpeaking(true); 00095 EXPECT_TRUE(robot.isSpeaking()); 00096 robot.setSpeaking(true); 00097 EXPECT_TRUE(robot.isSpeaking()); 00098 robot.setSpeaking(false); 00099 EXPECT_FALSE(robot.isSpeaking()); 00100 robot.setSpeaking(false); 00101 EXPECT_FALSE(robot.isSpeaking()); 00102 } 00103 00107 TEST(RobotTestSuite, testLooking) 00108 { 00109 Robot robot = Robot(); 00110 00111 std::vector<std::string> objects; 00112 objects.push_back("blue-plate"); 00113 00114 EXPECT_FALSE(robot.isLooking(std::vector<std::string>(objects))); 00115 EXPECT_EQ((unsigned)0, robot.getLooking().size()); 00116 00117 robot.setLookAt(true, objects); 00118 EXPECT_EQ(objects.size(), robot.getLooking().size()); 00119 EXPECT_EQ(objects.at(0), robot.getLooking().at(0)); 00120 00121 robot.setLookAt(true, objects); 00122 EXPECT_EQ(objects.size(), robot.getLooking().size()); 00123 EXPECT_EQ(objects.at(0), robot.getLooking().at(0)); 00124 00125 robot.setLookAt(false, objects); 00126 EXPECT_EQ((unsigned)0, robot.getLooking().size()); 00127 00128 robot.setLookAt(false, objects); 00129 EXPECT_EQ((unsigned)0, robot.getLooking().size()); 00130 00131 objects.clear(); 00132 00133 robot.setLookAt(true, objects); 00134 EXPECT_EQ((unsigned)0, robot.getLooking().size()); 00135 00136 objects.push_back("blue-plate"); 00137 objects.push_back("red-plate"); 00138 objects.push_back("green-plate"); 00139 00140 robot.setLookAt(true, objects); 00141 EXPECT_EQ(objects.size(), robot.getLooking().size()); 00142 EXPECT_EQ(objects.at(0), robot.getLooking().at(0)); 00143 EXPECT_EQ(objects.at(1), robot.getLooking().at(1)); 00144 EXPECT_EQ(objects.at(2), robot.getLooking().at(2)); 00145 00146 objects.clear(); 00147 00148 robot.setLookAt(true, objects); 00149 EXPECT_EQ((unsigned)0, robot.getLooking().size()); 00150 00151 objects.push_back("blue-plate"); 00152 objects.push_back("green-plate"); 00153 00154 robot.setLookAt(false, objects); 00155 EXPECT_EQ((unsigned)0, robot.getLooking().size()); 00156 00157 objects.clear(); 00158 objects.push_back("red-plate"); 00159 00160 robot.setLookAt(false, objects); 00161 EXPECT_EQ((unsigned)0, robot.getLooking().size()); 00162 } 00163 00167 TEST(RobotTestSuite, testPointing) 00168 { 00169 Robot robot = Robot(); 00170 00171 std::vector<std::string> objects; 00172 objects.push_back("blue-plate"); 00173 00174 EXPECT_FALSE(robot.isPointing(std::vector<std::string>(objects))); 00175 EXPECT_EQ((unsigned)0, robot.getPointing().size()); 00176 00177 robot.setPointAt(true, objects); 00178 EXPECT_TRUE(robot.isPointing(objects)); 00179 EXPECT_EQ(objects.size(), robot.getPointing().size()); 00180 EXPECT_EQ(objects.at(0), robot.getPointing().at(0)); 00181 00182 robot.setPointAt(true, objects); 00183 EXPECT_TRUE(robot.isPointing(objects)); 00184 EXPECT_EQ(objects.size(), robot.getPointing().size()); 00185 EXPECT_EQ(objects.at(0), robot.getPointing().at(0)); 00186 00187 robot.setPointAt(false, objects); 00188 EXPECT_FALSE(robot.isPointing(objects)); 00189 EXPECT_EQ((unsigned)0, robot.getPointing().size()); 00190 00191 robot.setPointAt(false, objects); 00192 EXPECT_FALSE(robot.isPointing(objects)); 00193 EXPECT_EQ((unsigned)0, robot.getPointing().size()); 00194 00195 objects.clear(); 00196 00197 robot.setPointAt(true, objects); 00198 EXPECT_FALSE(robot.isPointing(objects)); 00199 EXPECT_EQ((unsigned)0, robot.getPointing().size()); 00200 00201 objects.push_back("blue-plate"); 00202 objects.push_back("red-plate"); 00203 objects.push_back("green-plate"); 00204 00205 robot.setPointAt(true, objects); 00206 EXPECT_TRUE(robot.isPointing(objects)); 00207 EXPECT_EQ(objects.size(), robot.getPointing().size()); 00208 EXPECT_EQ(objects.at(0), robot.getPointing().at(0)); 00209 EXPECT_EQ(objects.at(1), robot.getPointing().at(1)); 00210 EXPECT_EQ(objects.at(2), robot.getPointing().at(2)); 00211 00212 objects.clear(); 00213 00214 robot.setPointAt(true, objects); 00215 EXPECT_FALSE(robot.isPointing(objects)); 00216 EXPECT_EQ((unsigned)3, robot.getPointing().size()); 00217 EXPECT_EQ("blue-plate", robot.getPointing().at(0)); 00218 EXPECT_EQ("red-plate", robot.getPointing().at(1)); 00219 EXPECT_EQ("green-plate", robot.getPointing().at(2)); 00220 00221 objects.push_back("blue-plate"); 00222 objects.push_back("green-plate"); 00223 00224 robot.setPointAt(false, objects); 00225 EXPECT_FALSE(robot.isPointing(objects)); 00226 EXPECT_EQ((unsigned)1, robot.getPointing().size()); 00227 EXPECT_EQ("red-plate", robot.getPointing().at(0)); 00228 00229 objects.clear(); 00230 objects.push_back("red-plate"); 00231 00232 robot.setPointAt(false, objects); 00233 EXPECT_FALSE(robot.isPointing(objects)); 00234 EXPECT_EQ((unsigned)0, robot.getPointing().size()); 00235 00236 objects.clear(); 00237 00238 robot.setPointAt(true, objects); 00239 EXPECT_FALSE(robot.isPointing(objects)); 00240 EXPECT_EQ((unsigned)0, robot.getPointing().size()); 00241 00242 objects.push_back("blue-plate"); 00243 objects.push_back("red-plate"); 00244 objects.push_back("green-plate"); 00245 00246 robot.setPointAt(true, objects); 00247 EXPECT_TRUE(robot.isPointing(objects)); 00248 00249 robot.donePoint(); 00250 EXPECT_FALSE(robot.isPointing(objects)); 00251 EXPECT_EQ((unsigned)0, robot.getPointing().size()); 00252 00253 robot.donePoint(); 00254 EXPECT_FALSE(robot.isPointing(objects)); 00255 EXPECT_EQ((unsigned)0, robot.getPointing().size()); 00256 } 00257 00261 TEST(RobotTestSuite, testWaiting) 00262 { 00263 Robot robot = Robot(); 00264 00265 EXPECT_FALSE(robot.isWaiting()); 00266 robot.setWaiting(true); 00267 EXPECT_TRUE(robot.isWaiting()); 00268 robot.setWaiting(true); 00269 EXPECT_TRUE(robot.isWaiting()); 00270 robot.setWaiting(false); 00271 EXPECT_FALSE(robot.isWaiting()); 00272 robot.setWaiting(false); 00273 EXPECT_FALSE(robot.isWaiting()); 00274 } |