コード例 #1
0
 protected void setUp() throws Exception {
   // we do need the resource manager for this test
   Fixture.setUpWithoutResourceManager();
   Fixture.createContext(false);
   // registration of real resource manager
   ResourceManager.register(new DefaultResourceManagerFactory());
   cache = new ImageDataCache();
 }
コード例 #2
0
  public void testActionPerformed() throws Exception {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);
    Display display = new Display();
    Shell shell = new Shell(display);
    Button button = new Button(shell, SWT.PUSH);
    IEventAdapter eventAdapter = (IEventAdapter) button.getAdapter(IEventAdapter.class);
    assertNotNull(eventAdapter);
    assertSame(eventAdapter, button.getAdapter(IEventAdapter.class));
    assertFalse(eventAdapter.hasListener(SelectionListener.class));
    try {
      eventAdapter.hasListener(Object.class);
      fail();
    } catch (final IllegalArgumentException iae) {
    }

    Object[] listener = eventAdapter.getListener(SelectionListener.class);
    assertEquals(0, listener.length);
    SelectionListener actionListener = new SelectionAdapter() {};
    eventAdapter.addListener(SelectionListener.class, actionListener);
    assertTrue(eventAdapter.hasListener(SelectionListener.class));
    listener = eventAdapter.getListener(SelectionListener.class);
    assertEquals(1, listener.length);
    assertSame(actionListener, listener[0]);
    eventAdapter.removeListener(SelectionListener.class, actionListener);
    assertFalse(eventAdapter.hasListener(SelectionListener.class));
  }
コード例 #3
0
  public void testComputeSize() throws Exception {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);
    Display display = new Display();
    Shell shell = new Shell(display, SWT.NONE);
    Group group = new Group(shell, SWT.NONE);
    group.setLayout(new FillLayout(SWT.VERTICAL));
    new Button(group, SWT.RADIO).setText("Radio 1");
    new Button(group, SWT.RADIO).setText("Radio 2");
    Point expected = new Point(70, 62);
    assertEquals(expected, group.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    group.setText("This is a very long group title.");
    expected = new Point(196, 62);
    assertEquals(expected, group.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    group = new Group(shell, SWT.BORDER);
    group.setLayout(new FillLayout(SWT.VERTICAL));
    new Button(group, SWT.RADIO).setText("Radio 1");
    new Button(group, SWT.RADIO).setText("Radio 2");
    expected = new Point(78, 70);
    assertEquals(expected, group.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    // hint + trimmings + border
    expected = new Point(114, 128);
    assertEquals(expected, group.computeSize(100, 100));
  }
コード例 #4
0
  public void testComputeTrim() throws Exception {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);
    Display display = new Display();
    Shell shell = new Shell(display, SWT.NONE);
    Group group = new Group(shell, SWT.NONE);
    // trimmings = 3, 17, 6, 20
    Rectangle expected = new Rectangle(-3, -17, 6, 20);
    assertEquals(expected, group.computeTrim(0, 0, 0, 0));

    expected = new Rectangle(17, 3, 106, 120);
    assertEquals(expected, group.computeTrim(20, 20, 100, 100));
  }
コード例 #5
0
  public void testClientArea() throws Exception {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);
    Display display = new Display();
    Shell shell = new Shell(display, SWT.NONE);
    Group group = new Group(shell, SWT.NONE);
    group.setText("This is a very long group title.");
    group.setSize(100, 100);
    group.setLayout(new FillLayout(SWT.VERTICAL));
    new Button(group, SWT.RADIO).setText("Radio 1");
    new Button(group, SWT.RADIO).setText("Radio 2");

    // trimmings = 3, 17, 6, 20
    Rectangle expected = new Rectangle(3, 17, 94, 80);
    assertEquals(expected, group.getClientArea());
  }
コード例 #6
0
 public void testAddListenerWithIllegalArguments() {
   Fixture.fakePhase(PhaseId.PROCESS_ACTION);
   Display display = new Display();
   Widget widget = new Shell(display);
   IEventAdapter eventAdapter = (IEventAdapter) widget.getAdapter(IEventAdapter.class);
   try {
     eventAdapter.addListener(SelectionListener.class, new Object());
     fail();
   } catch (final IllegalArgumentException iae) {
   }
   try {
     eventAdapter.addListener(SelectionListener.class, null);
     fail();
   } catch (final IllegalArgumentException iae) {
   }
   try {
     SelectionListener validListener = new SelectionAdapter() {};
     eventAdapter.addListener(null, validListener);
     fail();
   } catch (final IllegalArgumentException iae) {
   }
   Object[] listeners = eventAdapter.getListener(SelectionListener.class);
   assertEquals(0, listeners.length);
 }
コード例 #7
0
 protected void tearDown() throws Exception {
   Fixture.tearDown();
   Fixture.removeContext();
 }
コード例 #8
0
 protected void setUp() throws Exception {
   Fixture.setUp();
   Fixture.createContext(true);
 }
コード例 #9
0
 protected void tearDown() throws Exception {
   Fixture.tearDown();
 }
コード例 #10
0
 protected void setUp() throws Exception {
   Fixture.setUp();
 }
コード例 #11
0
 protected void setUp() throws Exception {
   Fixture.setUp();
   Fixture.fakePhase(PhaseId.PROCESS_ACTION);
 }