View | Details | Raw Unified | Return to bug 111637 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/gmf/tests/runtime/common/ui/internal/action/ActionManagerTest.java (-88 / +11 lines)
Lines 11-51 Link Here
11
11
12
package org.eclipse.gmf.tests.runtime.common.ui.internal.action;
12
package org.eclipse.gmf.tests.runtime.common.ui.internal.action;
13
13
14
import org.eclipse.core.runtime.IProgressMonitor;
15
16
import junit.framework.Test;
14
import junit.framework.Test;
17
import junit.framework.TestCase;
15
import junit.framework.TestCase;
18
import junit.framework.TestSuite;
16
import junit.framework.TestSuite;
19
import junit.textui.TestRunner;
17
import junit.textui.TestRunner;
20
18
19
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.gmf.runtime.common.core.command.CommandManager;
20
import org.eclipse.gmf.runtime.common.core.command.CommandManager;
22
import org.eclipse.gmf.runtime.common.ui.action.ActionManager;
21
import org.eclipse.gmf.runtime.common.ui.action.ActionManager;
23
import org.eclipse.gmf.runtime.common.ui.action.ActionManagerChangeEvent;
22
import org.eclipse.gmf.runtime.common.ui.action.ActionManagerChangeEvent;
24
import org.eclipse.gmf.runtime.common.ui.action.IActionManagerChangeListener;
23
import org.eclipse.gmf.runtime.common.ui.action.IActionManagerChangeListener;
25
import org.eclipse.gmf.runtime.common.ui.action.IRepeatableAction;
24
import org.eclipse.gmf.runtime.common.ui.action.IActionWithProgress;
26
25
27
/**
26
/**
28
 * @author khussey
27
 * @author khussey
29
 */
28
 */
30
public class ActionManagerTest extends TestCase {
29
public class ActionManagerTest extends TestCase {
31
30
32
    protected static class RepeatableAction implements IRepeatableAction {
31
    protected static class RepeatableAction implements IActionWithProgress {
33
32
34
        private final String label;
33
        private final String label;
35
34
36
        private final boolean runnable;
35
        private final boolean runnable;
37
36
38
        private final boolean repeatable;
39
40
        public RepeatableAction(
37
        public RepeatableAction(
41
            String label,
38
            String label,
42
            boolean runnable,
39
            boolean runnable) {
43
            boolean repeatable) {
44
            super();
40
            super();
45
41
46
            this.label = label;
42
            this.label = label;
47
            this.runnable = runnable;
43
            this.runnable = runnable;
48
            this.repeatable = repeatable;
49
        }
44
        }
50
45
51
        public String getLabel() {
46
        public String getLabel() {
Lines 56-69 Link Here
56
            return runnable;
51
            return runnable;
57
        }
52
        }
58
53
59
        public boolean isRepeatable() {
60
            return repeatable;
61
        }
62
63
        public void refresh() {/*Empty block*/}
54
        public void refresh() {/*Empty block*/}
64
55
65
        public void repeat(IProgressMonitor progressMonitor) {/*Empty block*/}
66
67
        public void run(IProgressMonitor progressMonitor) {/*Empty block*/}
56
        public void run(IProgressMonitor progressMonitor) {/*Empty block*/}
68
57
69
        public WorkIndicatorType getWorkIndicatorType() {
58
        public WorkIndicatorType getWorkIndicatorType() {
Lines 84-94 Link Here
84
            super(new CommandManager());
73
            super(new CommandManager());
85
        }
74
        }
86
75
87
        protected IRepeatableAction getFixtureAction() {
76
        protected IActionWithProgress getFixtureAction() {
88
            return super.getAction();
77
            return super.getAction();
89
        }
78
        }
90
79
91
        protected void setFixtureAction(IRepeatableAction action) {
80
        protected void setFixtureAction(IActionWithProgress action) {
92
            super.setAction(action);
81
            super.setAction(action);
93
        }
82
        }
94
83
Lines 240-333 Link Here
240
        }
229
        }
241
    }
230
    }
242
231
243
    public void test_canRepeat() {
244
        assertTrue(!getFixture().canRepeat());
245
246
        getFixture().setFixtureAction(
247
            new RepeatableAction(getName(), true, false));
248
        assertTrue(!getFixture().canRepeat());
249
250
        getFixture().setFixtureAction(
251
            new RepeatableAction(getName(), true, true));
252
        
253
        // RATLC00534581 - repeat no longer supported
254
        assertFalse(getFixture().canRepeat());
255
    }
256
257
    public void test_clear() {
232
    public void test_clear() {
258
        assertNull(getFixture().getFixtureAction());
233
        assertNull(getFixture().getFixtureAction());
259
234
260
        getFixture().setFixtureAction(
235
        getFixture().setFixtureAction(
261
            new RepeatableAction(getName(), true, true));
236
            new RepeatableAction(getName(), true));
262
        assertNotNull(getFixture().getFixtureAction());
237
        assertNotNull(getFixture().getFixtureAction());
263
238
264
        getFixture().clear();
239
        getFixture().clear();
265
        assertNull(getFixture().getFixtureAction());
240
        assertNull(getFixture().getFixtureAction());
266
    }
241
    }
267
242
268
    public void test_getRepeatLabel() {
269
        assertEquals(
270
            ActionManager.REPEAT_LABEL_PREFIX,
271
            getFixture().getRepeatLabel());
272
273
        getFixture().setFixtureAction(
274
            new RepeatableAction(getName(), true, false));
275
        assertEquals(
276
            ActionManager.REPEAT_LABEL_PREFIX,
277
            getFixture().getRepeatLabel());
278
279
        getFixture().setFixtureAction(
280
            new RepeatableAction(getName(), true, true));
281
        assertEquals(ActionManager.REPEAT_LABEL_PREFIX, getFixture().getRepeatLabel());
282
        
283
        getFixture().setFixtureAction(null);
284
        
285
        // RATLC00534581 - repeat no longer supported
286
        assertEquals(ActionManager.REPEAT_LABEL_PREFIX, getFixture().getRepeatLabel());
287
    }
288
289
    public void test_repeat() {
290
        assertNull(getFixture().getFixtureAction());
291
292
        try {
293
            getFixture().repeat();
294
            fail();
295
        } catch (UnsupportedOperationException uoe) {
296
            assertNull(getFixture().getFixtureAction());
297
        }
298
299
        IRepeatableAction action = new RepeatableAction(getName(), true, false);
300
        getFixture().setFixtureAction(action);
301
302
        try {
303
            getFixture().repeat();
304
            fail();
305
        } catch (UnsupportedOperationException uoe) {
306
            assertSame(action, getFixture().getFixtureAction());
307
        }
308
309
        action = new RepeatableAction(getName(), true, true);
310
        getFixture().setFixtureAction(action);
311
312
        try {
313
            getFixture().repeat();            
314
            fail("Expect exception because repeat is disabled."); //$NON-NLS-1$
315
        } catch (UnsupportedOperationException uoe) {
316
        	// RATLC00534581 - repeat no longer supported
317
        }
318
    }
319
320
    public void test_run() {
243
    public void test_run() {
321
        assertNull(getFixture().getFixtureAction());
244
        assertNull(getFixture().getFixtureAction());
322
245
323
        try {
246
        try {
324
            getFixture().run(new RepeatableAction(getName(), false, false));
247
            getFixture().run(new RepeatableAction(getName(), false));
325
            fail();
248
            fail();
326
        } catch (UnsupportedOperationException uoe) {
249
        } catch (UnsupportedOperationException uoe) {
327
            assertNull(getFixture().getFixtureAction());
250
            assertNull(getFixture().getFixtureAction());
328
        }
251
        }
329
252
330
        IRepeatableAction action = new RepeatableAction(getName(), true, false);
253
        IActionWithProgress action = new RepeatableAction(getName(), true);
331
        try {
254
        try {
332
            getFixture().run(action);
255
            getFixture().run(action);
333
            assertSame(action, getFixture().getFixtureAction());
256
            assertSame(action, getFixture().getFixtureAction());
Lines 336-348 Link Here
336
        }
259
        }
337
260
338
        try {
261
        try {
339
            getFixture().run(new RepeatableAction(getName(), false, true));
262
            getFixture().run(new RepeatableAction(getName(), false));
340
            fail();
263
            fail();
341
        } catch (UnsupportedOperationException uoe) {
264
        } catch (UnsupportedOperationException uoe) {
342
            assertSame(action, getFixture().getFixtureAction());
265
            assertSame(action, getFixture().getFixtureAction());
343
        }
266
        }
344
267
345
        action = new RepeatableAction(getName(), true, true);
268
        action = new RepeatableAction(getName(), true);
346
        try {
269
        try {
347
            getFixture().run(action);
270
            getFixture().run(action);
348
            assertSame(action, getFixture().getFixtureAction());
271
            assertSame(action, getFixture().getFixtureAction());

Return to bug 111637