Node C = main.addNode("C");
main.addEdge("AB", "A", "B");
main.addEdge("BC", "B", "C");
main.addEdge("CA", "C", "A");
SpriteManager sman = new SpriteManager(main);
Sprite S1 = sman.addSprite("S1");
Sprite S2 = sman.addSprite("S2");
Sprite S3 = sman.addSprite("S3");
S3.setPosition(1, 2, 2);
S3.setPosition(2, 3, 2);
S3.setPosition(3, 2, 1);
A.addAttribute("ui.foo", "bar");
B.addAttribute("ui.bar", "foo");
C.addAttribute("truc"); // Not prefixed by UI, will not pass.
S1.addAttribute("ui.foo", "bar");
main.stepBegins(1);
toMain.pump();
// We ask the Swing thread to modify the graphic graph.
main.stepBegins(2);
main.addAttribute("ui.EQUIP"); // Remember GraphicGraph filters
// attributes.
// Wait and stop.
toMain.pump();
sleep(1000);
toMain.pump();
main.addAttribute("ui.STOP");
toMain.pump();
sleep(1000);
toMain.pump();
// ****************************************************************************************
// Now we can begin the real test. We ensure the timer in the Swing
// graph stopped and check
// If the two graphs (main and graphic) synchronized correctly.
GraphicGraph graphic = viewerThread.graphic;
assertTrue(viewerThread.isStopped());
assertFalse(main.hasAttribute("ui.EQUIP"));
assertFalse(graphic.hasAttribute("ui.EQUIP"));
assertTrue(main.hasAttribute("ui.STOP"));
assertTrue(graphic.hasAttribute("ui.STOP"));
assertEquals(3, graphic.getStep(), 0);
assertEquals(2, main.getStep(), 0); // We do not listen at elements events
// the step 3
// of the graphic graph did not
// reached us.
// Assert all events passed toward the graphic graph.
assertEquals(3, graphic.getNodeCount());
assertEquals(3, graphic.getEdgeCount());
assertEquals(3, graphic.getSpriteCount());
assertNotNull(graphic.getNode("A"));
assertNotNull(graphic.getNode("B"));
assertNotNull(graphic.getNode("C"));
assertNotNull(graphic.getEdge("AB"));
assertNotNull(graphic.getEdge("BC"));
assertNotNull(graphic.getEdge("CA"));
assertNotNull(graphic.getSprite("S1"));
assertNotNull(graphic.getSprite("S2"));
assertEquals("bar", graphic.getNode("A").getAttribute("ui.foo"));
assertEquals("foo", graphic.getNode("B").getAttribute("ui.bar"));
// assertNull( graphic.getNode("C").getAttribute( "truc" ) ); // Should
// not pass the attribute filter.
assertEquals("bar", graphic.getSprite("S1").getAttribute("ui.foo"));
assertEquals("bar", sman.getSprite("S1").getAttribute("ui.foo"));
// Assert attributes passed back to the graph from the graphic graph.
Object xyz1[] = { 4, 3, 2 };
Object xyz2[] = { 2, 1, 0 };