Project: engagement_generation License: BSD Dependencies:
Used by:
None |
engagement_generation/test/edu/wpi/hri/gen/policy/DefaultGazePolicyTest.javaGo to the documentation of this file.00001 package edu.wpi.hri.gen.policy; 00002 00003 import junit.framework.TestCase; 00004 00005 import org.junit.Test; 00006 00007 import ros.NodeHandle; 00008 import ros.Ros; 00009 import ros.RosException; 00010 import edu.wpi.hri.bml.XMLInterface; 00011 import edu.wpi.hri.comm.MasterSpinner; 00012 import edu.wpi.hri.gen.Generation; 00013 import edu.wpi.hri.gen.comm.BMLRealizer; 00014 import edu.wpi.hri.gen.comm.GazeKnowledge; 00015 import edu.wpi.hri.log.Logger; 00016 00017 public class DefaultGazePolicyTest extends TestCase { 00018 00019 private boolean called = false; 00020 00021 @Test 00022 public void testPolicy() throws RosException { 00023 Logger logger = Logger.createDefault(); 00024 XMLInterface xml = Generation.createXML(logger); 00025 NodeHandle handle = Ros.getInstance().createNodeHandle(); 00026 MasterSpinner spin = new MasterSpinner(logger, false); 00027 BMLRealizer realizer = new BMLRealizer(handle, spin, logger); 00028 GazeKnowledge gaze = new GazeKnowledge(handle, logger, xml, realizer) { 00029 @Override 00030 public boolean trySetGaze(String target) { 00031 called = true; 00032 return true; 00033 } 00034 }; 00035 DefaultGazePolicy policy = new DefaultGazePolicy(logger, handle, gaze, gaze); 00036 00037 called = false; 00038 policy.gazeChanged("test-face", true, false); 00039 assertFalse(called); 00040 00041 policy.gazeChanged("test-face", false, false); 00042 assertFalse(called); 00043 00044 policy.gazeChanged(null, false, false); 00045 assertTrue(called); 00046 00047 called = false; 00048 policy.gazeChanged("", false, false); 00049 assertTrue(called); 00050 00051 policy.shutdown(); 00052 gaze.shutdown(); 00053 realizer.shutdown(); 00054 spin.stop(); 00055 spin.joinOldMasters(); 00056 handle.shutdown(); 00057 } 00058 } |