01: package org.uispec4j.interception;
02:
03: import org.uispec4j.Trigger;
04:
05: import javax.swing.*;
06:
07: public class PopupMenuInterceptionTest extends InterceptionTestCase {
08: public void test() throws Exception {
09: String[] items = { "item 1", "item 2" };
10: PopupMenuInterceptor.run(new PopupTrigger(items))
11: .contentEquals(items);
12: }
13:
14: private static class PopupTrigger implements Trigger {
15: JPopupMenu popup = new JPopupMenu();
16:
17: public PopupTrigger(String[] items) {
18: for (int i = 0; i < items.length; i++) {
19: popup.add(items[i]);
20: }
21: }
22:
23: public void run() throws Exception {
24: popup.show(null, 100, 100);
25: }
26: }
27: }
|