01: package abbot.editor;
02:
03: import junit.extensions.abbot.*;
04: import abbot.script.*;
05:
06: /** Verify operation of ScriptModel. */
07:
08: public class ScriptModelTest extends ResolverFixture {
09:
10: private Script script;
11: private ScriptModel model;
12:
13: public void testInsertBefore() {
14: Sequence s1 = new Sequence(script, "sequence 1", null);
15: Step s2 = new Comment(script, "step 2");
16: Step s3 = new Comment(script, "step 3");
17: script.addStep(s1);
18: script.addStep(s2);
19: script.addStep(s3);
20: // 1 2 3
21: model.setScript(script);
22: Step s4 = new Comment(script, "step 4");
23: model.insertStep(script, s4, 0);
24: // 4 1 2 3
25: assertEquals("Step 4 in wrong location", 0, script.indexOf(s4));
26: Step s5 = new Comment(script, "step 5");
27: model.toggle(1);
28: model.insertStep(script, s5, 1);
29: // 4 5 1 2 3
30: assertEquals("Step 5 in wrong location", 1, script.indexOf(s5));
31: }
32:
33: public void testInsertAfter() {
34: Sequence s1 = new Sequence(script, "sequence 1", null);
35: Step s2 = new Comment(script, "step 2");
36: Step s3 = new Comment(script, "step 3");
37: script.addStep(s1);
38: script.addStep(s2);
39: script.addStep(s3);
40: // 1 2 3
41: model.setScript(script);
42: Step s4 = new Comment(script, "step 4");
43: model.insertStep(script, s4, 1);
44: // 1 4 2 3
45: assertEquals("Step 4 in wrong location", 1, script.indexOf(s4));
46: Step s5 = new Comment(script, "step 5");
47: model.toggle(0);
48: assertTrue("Sequence 1 should be open", model.isOpen(0));
49: model.insertStep(s1, s5, 0);
50: // 1(5) 4 2 3
51: assertEquals("Step 5 should be moved out of script", -1, script
52: .indexOf(s5));
53: assertEquals("Step 5 should be within sequence 1", 0, s1
54: .indexOf(s5));
55: }
56:
57: protected void setUp() throws Exception {
58: script = new Script(getHierarchy());
59: script.setDescription(getName());
60: model = new ScriptModel();
61: }
62:
63: /** Construct a test case with the given name. */
64: public ScriptModelTest(String name) {
65: super (name);
66: }
67:
68: /** Run the default test suite. */
69: public static void main(String[] args) {
70: TestHelper.runTests(args, ScriptModelTest.class);
71: }
72: }
|