Index: /trunk/tests/org/expeditee/gui/FrameIOTest.java
===================================================================
--- /trunk/tests/org/expeditee/gui/FrameIOTest.java	(revision 40)
+++ /trunk/tests/org/expeditee/gui/FrameIOTest.java	(revision 40)
@@ -0,0 +1,82 @@
+package org.expeditee.gui;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class FrameIOTest {
+
+	@BeforeClass
+	public static void setUpBeforeClass() throws Exception {
+	}
+
+	@AfterClass
+	public static void tearDownAfterClass() throws Exception {
+	}
+
+	@Before
+	public void setUp() throws Exception {
+	}
+
+	@After
+	public void tearDown() throws Exception {
+	}
+
+	@Test
+	public void isValidFrameName() {
+		assertThat(FrameIO.isValidFrameName("a1"), is(true));
+		assertThat(FrameIO.isValidFrameName("a1c1"), is(true));
+		assertThat(FrameIO.isValidFrameName("1a1"), is(false));
+		assertThat(FrameIO.isValidFrameName("$a1"), is(false));
+		assertThat(FrameIO.isValidFrameName("aa"), is(false));
+		assertThat(FrameIO.isValidFrameName("a1.1"), is(false));
+		assertThat(FrameIO.isValidFrameName(null), is(false));
+		assertThat(FrameIO.isValidFrameName("1"), is(false));
+		assertThat(FrameIO.isValidFrameName("a"), is(false));
+		assertThat(FrameIO.isValidFrameName(""), is(false));
+	}
+	
+	@Test
+	public void isValidFramesetName() {
+		assertThat(FrameIO.IsValidFramesetName("a"), is(true));
+		assertThat(FrameIO.IsValidFramesetName("a1c"), is(true));
+		assertThat(FrameIO.IsValidFramesetName("1a"), is(false));
+		assertThat(FrameIO.IsValidFramesetName("$a"), is(false));
+		assertThat(FrameIO.IsValidFramesetName("a$"), is(false));
+		assertThat(FrameIO.IsValidFramesetName("a.a"), is(false));
+		assertThat(FrameIO.IsValidFramesetName(null), is(false));
+		assertThat(FrameIO.IsValidFramesetName("1"), is(false));
+		assertThat(FrameIO.isValidFrameName(""), is(false));
+		assertThat(FrameIO.IsValidFramesetName("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz012345678901A"), is(false));
+		
+	}
+	
+	@Test
+	public void ConvertToFramesetName() {
+		assertThat(FrameIO.ConvertToValidFramesetName("a"), is("a"));
+		assertThat(FrameIO.ConvertToValidFramesetName("a b"), is("aB"));
+		assertThat(FrameIO.ConvertToValidFramesetName("1a"), is("A1a"));
+		assertThat(FrameIO.ConvertToValidFramesetName("$a"), is("A"));
+		assertThat(FrameIO.ConvertToValidFramesetName("a$"), is("a"));
+		assertThat(FrameIO.ConvertToValidFramesetName("a.a"), is("aA"));
+		assertThat(FrameIO.ConvertToValidFramesetName("1"), is("A1A"));
+		assertThat(FrameIO.ConvertToValidFramesetName("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz01234567890123456789"),
+				is("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz01234567890A"));
+		
+	}
+	
+	/*@Test(expected=RuntimeException.class) 
+	  public void ConvertToFramesetNameException() {
+		FrameIO.ConvertToValidFramesetName(null);
+	}
+	
+	@Test(expected=RuntimeException.class) 
+	  public void ConvertToFramesetNameException2() {
+		FrameIO.ConvertToValidFramesetName("");
+	}*/
+}
Index: /trunk/tests/org/expeditee/gui/FrameTest.java
===================================================================
--- /trunk/tests/org/expeditee/gui/FrameTest.java	(revision 40)
+++ /trunk/tests/org/expeditee/gui/FrameTest.java	(revision 40)
@@ -0,0 +1,252 @@
+package org.expeditee.gui;
+
+import java.awt.Dimension;
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class FrameTest extends TestCase {
+	
+	public void testConstructor() { // the most trivial test in the world
+		Frame f = new Frame();
+		assertNotNull(f);
+	}
+	
+	public void testEquals1() {
+		Frame f1 = new Frame();
+		Frame f2 = new Frame();
+		assertEquals(f1, f2);
+		assertEquals(f2, f1);
+	}
+	
+	public void testEquals2() {
+		
+		Frame f1 = new Frame();
+		f1.setFrameset("safhsfah");
+		
+		Frame f2 = new Frame();
+		
+		assertFalse(f1.equals(f2));
+		assertFalse(f2.equals(f1));
+	}
+	
+	public void testAddGetSingleOverlay() {
+		Frame f = new Frame();
+		List<Overlay> overlays = f.getOverlays();
+		assertNotNull(overlays);
+		assertEquals(0, overlays.size());
+		
+		Overlay o = new Overlay(new Frame(), 0);
+		f.addOverlay(o);
+		assertEquals(0, overlays.size()); // getOverlays should be immutable
+		overlays = f.getOverlays();
+		assertNotNull(overlays);
+		assertEquals(1, overlays.size());
+		assertEquals(o, overlays.get(0));
+	}
+	
+	public void testAddGetMultipleOverlays() {
+		
+		// TODO: REMOVE THIS LINE - THIS SHOULD NOT BE NEEDED - OTHER TEST CAPTURE THIS ERROR
+		FrameGraphics.setMaxSize(new Dimension(100,100));
+		
+		Frame f1 = new Frame(); f1.setFrameset("dgadag"); f1.setFrameName("dgad3ag");
+		Frame f2 = new Frame(); f2.setFrameset("fsdf"); f2.setFrameName("f4df");
+		Frame f3 = new Frame(); f3.setFrameset("iuyf"); f3.setFrameName("iu5yf");
+		Frame f4 = new Frame(); f4.setFrameset("rs"); f4.setFrameName("r6s");
+		
+		Overlay o1 = new Overlay(f1, 0);
+		Overlay o2 = new Overlay(f2, 1);
+		Overlay o3 = new Overlay(f3, 2);
+		Overlay o4 = new Overlay(f4, 3);
+		
+		Frame root = new Frame(); root.setFrameset("roottest"); root.setFrameName("roottest");
+		
+		root.addOverlay(o1);
+		
+		List<Overlay> overlays = root.getOverlays();
+		assertNotNull(overlays);
+		assertEquals(1, overlays.size());
+		assertEquals(o1, overlays.get(0));
+		
+		f3.addOverlay(o2);
+		root.addOverlay(o3);
+		
+		overlays = root.getOverlays();
+		assertNotNull(overlays);
+		assertEquals(2, overlays.size());
+		assertTrue(overlays.contains(o1));
+		assertTrue(overlays.contains(o3));
+		
+		overlays.clear();
+		overlays.add(new Overlay(new Frame(), 0));
+		overlays.add(new Overlay(new Frame(), 1));
+		overlays.add(new Overlay(new Frame(), 2));
+		overlays.add(o4);
+		overlays.add(new Overlay(new Frame(), 3));
+		overlays.add(new Overlay(new Frame(), 4));
+		String framesetname = "X";
+		for (Overlay o : overlays) {
+			if (o.Frame.getFramesetName() == null) {
+				o.Frame.setFrameName(framesetname);
+				o.Frame.setFrameName(framesetname + "name");
+				framesetname = framesetname + "X";
+				
+			}
+		}
+		root.addAllOverlays(overlays);
+
+		overlays = root.getOverlays();
+		assertNotNull(overlays);
+		assertEquals(8, overlays.size());
+		assertTrue(overlays.contains(o1));
+		assertTrue(overlays.contains(o3));
+		assertTrue(overlays.contains(o4));
+		
+	}
+	
+	public void testClearOverlays() {
+		
+		// TODO: REMOVE THIS LINE - THIS SHOULD NOT BE NEEDED - OTHER TEST CAPTURE THIS ERROR
+		FrameGraphics.setMaxSize(new Dimension(100,100));
+		
+		List<Overlay> overlays = new LinkedList<Overlay>();
+		overlays.add(new Overlay(new Frame(), 0));
+		overlays.add(new Overlay(new Frame(), 1));
+		overlays.add(new Overlay(new Frame(), 2));
+		overlays.add(new Overlay(new Frame(), 3));
+		overlays.add(new Overlay(new Frame(), 4));
+		String framesetname = "X";
+		for (Overlay o : overlays) {
+			o.Frame.setFrameName(framesetname);
+			o.Frame.setFrameName(framesetname + "name");
+			framesetname = framesetname + "X";
+		}
+		Frame root = new Frame(); root.setFrameset("roottest"); root.setFrameName("roottest");
+		
+		root.addAllOverlays(overlays);
+		
+		root.clearOverlays();
+		overlays = root.getOverlays();
+		assertNotNull(overlays);
+		assertEquals(0, overlays.size());
+	}
+	
+	public void testRemoveOverlay() {
+		
+		// TODO: REMOVE THIS LINE - THIS SHOULD NOT BE NEEDED - OTHER TEST CAPTURE THIS ERROR
+		FrameGraphics.setMaxSize(new Dimension(100,100));
+		
+		List<Overlay> overlays = new LinkedList<Overlay>();
+		Overlay toRemove = new Overlay(new Frame(), 1);
+		overlays.add(new Overlay(new Frame(), 0));
+		overlays.add(toRemove);
+		overlays.add(new Overlay(new Frame(), 2));
+		overlays.add(new Overlay(new Frame(), 3));
+		overlays.add(new Overlay(new Frame(), 4));
+		String framesetname = "X";
+		for (Overlay o : overlays) {
+			o.Frame.setFrameName(framesetname);
+			o.Frame.setFrameName(framesetname + "name");
+			framesetname = framesetname + "X";
+		}
+		Frame root = new Frame(); root.setFrameset("roottest"); root.setFrameName("roottest");
+		
+		root.addAllOverlays(overlays);
+		
+		root.removeOverlay(toRemove.Frame);
+		overlays = root.getOverlays();
+		assertNotNull(overlays);
+		assertEquals(4, overlays.size());
+		assertFalse(overlays.contains(toRemove));
+	}
+	
+		
+	
+	public void testGetOverlaysDeep() {
+		
+		// TODO: REMOVE THIS LINE - THIS SHOULD NOT BE NEEDED - OTHER TEST CAPTURE THIS ERROR
+		FrameGraphics.setMaxSize(new Dimension(100,100));
+		
+		Frame f1 = new Frame(); f1.setFrameset("dgadag"); f1.setFrameName("dgad3ag");
+		Frame f2 = new Frame(); f2.setFrameset("fsdf"); f2.setFrameName("f4df");
+		Frame f3 = new Frame(); f3.setFrameset("iuyf"); f3.setFrameName("iu5yf");
+		Frame f4 = new Frame(); f4.setFrameset("rs"); f4.setFrameName("r6s");
+		Frame f5 = new Frame(); f5.setFrameset("danfui"); f5.setFrameName("hfjty");
+		
+		Overlay o0 = new Overlay(f1, 0);
+		Overlay o1 = new Overlay(f1, 4);
+		Overlay o2 = new Overlay(f2, 1);
+		Overlay o3 = new Overlay(f3, 2);
+		Overlay o4 = new Overlay(f4, 3);
+		Overlay o5 = new Overlay(f5, 2);
+		
+		f1.addOverlay(o2);
+		f2.addOverlay(o3);
+		f3.addOverlay(o4);
+		
+		Frame root = new Frame(); root.setFrameset("roottest"); root.setFrameName("roottest");
+		
+		
+		root.addOverlay(o0);
+		List<Overlay> overlays = root.getOverlays();
+		assertNotNull(overlays);
+		assertEquals(1, overlays.size());
+		assertEquals(o0, overlays.get(0));
+		
+		overlays = root.getOverlaysDeep();
+		assertNotNull(overlays);
+		assertEquals(4, overlays.size());
+		assertTrue(overlays.contains(o0));
+		assertTrue(overlays.contains(o2));
+		assertTrue(overlays.contains(o3));
+		assertTrue(overlays.contains(o4));
+		
+		
+		f3.addOverlay(o5);
+		overlays = root.getOverlaysDeep();
+		assertNotNull(overlays);
+		assertEquals(5, overlays.size());
+		assertTrue(overlays.contains(o0));
+		assertTrue(overlays.contains(o2));
+		assertTrue(overlays.contains(o3));
+		assertTrue(overlays.contains(o4));
+		assertTrue(overlays.contains(o5));
+		
+		root.clearOverlays();
+		
+		overlays = root.getOverlaysDeep();
+		assertNotNull(overlays);
+		assertEquals(0, overlays.size());
+		
+		overlays.clear();
+		overlays.add(new Overlay(new Frame(), 0));
+		overlays.add(new Overlay(new Frame(), 1));
+		overlays.add(new Overlay(new Frame(), 2));
+		overlays.add(new Overlay(new Frame(), 3));
+		overlays.add(new Overlay(new Frame(), 4));
+		String framesetname = "X";
+		for (Overlay o : overlays) {
+			if (o.Frame.getFramesetName() == null) {
+				o.Frame.setFrameName(framesetname);
+				o.Frame.setFrameName(framesetname + "name");
+				framesetname = framesetname + "X";
+				
+			}
+		}
+		root.addAllOverlays(overlays);
+		root.addOverlay(o1);
+
+		overlays = root.getOverlaysDeep();
+		assertNotNull(overlays);
+		assertEquals(10, overlays.size());
+		
+		f2.removeOverlay(f3);
+		
+		overlays = root.getOverlaysDeep();
+		assertNotNull(overlays);
+		assertEquals(7, overlays.size());
+	}
+	
+}
