### Question:
ScreenPositionManager implements ViewChangeListener, DiscreteEventListener { public void close() { ControlContext globeContext = myControlRegistry.getControlContext(ControlRegistry.GLOBE_CONTROL_CONTEXT); globeContext.removeListener(this); myMapManager.getViewChangeSupport().removeViewChangeListener(this); myModel.setScreenPosition(null, null, null, null); myModel.setGeoPosition(null, null, null, null, null); } ScreenPositionManager(MapManager mapManager, ControlRegistry controlRegistry, XrayGogglesModel model); void close(); @Override void eventOccurred(InputEvent event); @Override String getCategory(); @Override String getDescription(); @Override int getTargetPriority(); @Override String getTitle(); @Override boolean isReassignable(); @Override boolean isTargeted(); @Override boolean mustBeTargeted(); @Override void viewChanged(Viewer viewer, ViewChangeSupport.ViewChangeType type);  }### Answer:
@Test public void test() throws InterruptedException { EasyMockSupport support = new EasyMockSupport(); ScreenViewer viewer = createViewer(support); DynamicViewer standardViewer = support.createMock(DynamicViewer.class); EasyMock.expect(Double.valueOf(standardViewer.getPitch())).andReturn(Double.valueOf(Math.toRadians(45))).atLeastOnce(); MapManager mapManager = createMapManager(support, viewer, standardViewer); ControlRegistry controlRegistry = createControlRegistry(support); support.replayAll(); XrayGogglesModel model = new XrayGogglesModel(); ScreenPositionManager manager = new ScreenPositionManager(mapManager, controlRegistry, model); assertEquals(480, model.getUpperLeft().getX(), 0d); assertEquals(720, model.getUpperLeft().getY(), 0d); assertEquals(1440, model.getUpperRight().getX(), 0d); assertEquals(720, model.getUpperRight().getY(), 0d); assertEquals(640, model.getLowerLeft().getX(), 0d); assertEquals(1080, model.getLowerLeft().getY(), 0d); assertEquals(1280, model.getLowerRight().getX(), 0d); assertEquals(1080, model.getLowerRight().getY(), 0d); model.addObserver((o, arg) -> { myLatch.countDown(); }); myLatch = new CountDownLatch(1); mapManager.getViewChangeSupport().notifyViewChangeListeners(viewer, (r) -> { r.run(); }, ViewChangeType.WINDOW_RESIZE); assertTrue(myLatch.await(1, TimeUnit.SECONDS)); assertEquals(240, model.getUpperLeft().getX(), 0d); assertEquals(360, model.getUpperLeft().getY(), 0d); assertEquals(720, model.getUpperRight().getX(), 0d); assertEquals(360, model.getUpperRight().getY(), 0d); assertEquals(320, model.getLowerLeft().getX(), 0d); assertEquals(540, model.getLowerLeft().getY(), 0d); assertEquals(640, model.getLowerRight().getX(), 0d); assertEquals(540, model.getLowerRight().getY(), 0d); mapManager.getViewChangeSupport().notifyViewChangeListeners(viewer, (r) -> { r.run(); }, ViewChangeType.NEW_VIEWER); mapManager.getViewChangeSupport().notifyViewChangeListeners(viewer, (r) -> { r.run(); }, ViewChangeType.VIEW_CHANGE); manager.close(); assertNull(model.getUpperLeft()); assertNull(model.getUpperRight()); assertNull(model.getLowerLeft()); assertNull(model.getLowerRight()); assertNull(model.getCenterGeo()); assertNull(model.getUpperLeftGeo()); assertNull(model.getUpperRightGeo()); assertNull(model.getLowerLeftGeo()); assertNull(model.getLowerRightGeo()); mapManager.getViewChangeSupport().notifyViewChangeListeners(viewer, (r) -> { r.run(); }, ViewChangeType.WINDOW_RESIZE); Thread.sleep(100); support.verifyAll(); }