### Question:
MediaStreamer implements ServerLobbyListener, CaptureObserver { public synchronized void updateDeviceList() { if(currentStream != null) { log.error("Attempted to update capture list while serving a stream."); return; } List<CameraController> oldCameras = cameras; CameraController oldActiveCam = getActiveCamera(); cameras = new ArrayList<CameraController>(); NativeCaptureSystemFactory captureFactory = new NativeCaptureSystemFactory(); try { CaptureSystem captureSystem = captureFactory.createCaptureSystem(); captureSystem.init(); List<com.lti.civil.CaptureDeviceInfo> devices = captureSystem.getCaptureDeviceInfoList(); for(com.lti.civil.CaptureDeviceInfo device : devices) { log.info("LTI-Civil found device: " + device.getDescription() + " - " + device.getDeviceID()); boolean foundExisting = false; for(CameraController c : oldCameras) { if(c.getDeviceId().equals(device.getDeviceID())) { cameras.add(c); foundExisting = true; break; } } if(!foundExisting) { CameraController newCam = new CameraController(device); cameras.add(newCam); } } if(cameras.isEmpty()) { selectedCamera = null; } else { if(cameras.contains(oldActiveCam)) { setActiveCamera(oldActiveCam); } else { setActiveCamera(cameras.get(0)); } } } catch (CaptureException e) { e.printStackTrace(); } } MediaStreamer(int port); int getPort(); synchronized void updateDeviceList(); CameraController getActiveCamera(); synchronized void playStream(); synchronized void setObserver(CaptureObserver observer); synchronized void stopStream(); void setActiveCamera(CameraController newCam); List<CameraController> getAvailableCameras(); boolean isStreaming(); boolean addUser(User user); boolean removeUser(User user); boolean isServingUser(User user); int getNumUsers(); @Override /** * Starts and stops the network video stream when a game is launched * or terminated. */ void lobbyGameStateChanged(LobbyGameEvent event); @Override /** * Adds and removes users from the streaming media client list when a user * joins or leaves the server lobby. */ void userStateChanged(LobbyUserEvent event); @Override void robotStateChanged(LobbyRobotEvent event); @Override void lobbyChatMessage(LobbyChatEvent event); @Override /** Logs errors in the capture stream */ void onError(CaptureStream stream, CaptureException err); @Override /** Called whenever a new frame is read from the active capture stream */ void onNewImage(CaptureStream stream, Image image); static boolean ENABLE_TEST_CLIENT; static String TEST_CLIENT_HOSTNAME; static long IMAGE_WRITE_INTERVAL; static int VIDEO_WIDTH; static int VIDEO_HEIGHT; static int INC_BUFFER_SIZE; static int PACKET_SIZE; }### Answer:
@Test public void testUpdateDeviceList() { testMedia.updateDeviceList(); assertEquals(true, testMedia.getActiveCamera() != null); CameraController activeCam = testMedia.getActiveCamera(); activeCam.setFov(100); activeCam.setPosition(100, 200, 300); activeCam.setOrientation(20, 60); assertEquals(100, activeCam.getFov(), 0.05); assertEquals(100, activeCam.getxPos(), 0.05); assertEquals(200, activeCam.getyPos(), 0.05); assertEquals(300, activeCam.getzPos(), 0.05); assertEquals(20, activeCam.getHorOrientation(), 0.05); assertEquals(60, activeCam.getVerOrientation(), 0.05); assertEquals(true, activeCam.getCameraName() != null); assertEquals(true, activeCam.getDeviceId() != null); testMedia.updateDeviceList(); assertEquals(activeCam, testMedia.getActiveCamera()); }