public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: New RepaintManager test
@ 2005-10-18 15:03 Roman Kennke
  0 siblings, 0 replies; only message in thread
From: Roman Kennke @ 2005-10-18 15:03 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]

Here comes a test for RepaintManager that checks a little functionality
in addDirtyRegion.

2005-10-18  Roman Kennke  <kennke@aicas.com>

        * gnu/testlet/javax/swing/RepaintManager/DisabledEventQueue.java:
        Auxiliary helper class.
        * gnu/testlet/javax/swing/RepaintManager/addDirtyRegion.java
        New test.


/Roman

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: addDirtyRegion.java --]
[-- Type: text/x-java; name="addDirtyRegion.java", Size: 2378 bytes --]

// Tags: JDK1.2
// Uses: DisabledEventQueue

// Copyright (C) 2005 Roman Kennke <kennke@aicas.com>

// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version. 

// Mauve is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING.  If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.  */

package gnu.testlet.javax.swing.RepaintManager;

import java.awt.Rectangle;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.RepaintManager;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

/**
 * Checks the addDirtyRegion method. More specifically, this checks if
 * addDirtyRegion does any optimization or not.
 *
 * @author Roman Kennke (kennke@aicas.com)
 */
public class addDirtyRegion implements Testlet
{

  /**
   * Starts the test run.
   *
   * @param harness the test harness to use
   */
  public void test(TestHarness harness)
  {
    test1(harness);
  }

  /**
   * Adds a dirty region for a component and checks if it is correctly
   * returned by getDirtyRegion() and isCompletelyDirty().
   *
   * @param harness the test harness to use
   */
  private void test1(TestHarness harness)
  {
    // Disable event queue to prevent the RepaintManager from working.
    Toolkit.getDefaultToolkit().getSystemEventQueue()
    .push(new DisabledEventQueue());

    JFrame f = new JFrame();
    JLabel l = new JLabel("Hello");
    f.getContentPane().add(l);
    l.setSize(100, 100);
    f.setSize(200, 200);
    f.setVisible(true);
    RepaintManager rm = RepaintManager.currentManager(l);
    rm.addDirtyRegion(l, 0, 0, l.getWidth(), l.getHeight());
    harness.check(rm.isCompletelyDirty(l), false);
    Rectangle dirty = rm.getDirtyRegion(l);
    harness.check(dirty.x, 0);
    harness.check(dirty.y, 0);
    harness.check(dirty.width, l.getWidth());
    harness.check(dirty.height, l.getHeight());
  }
}

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: DisabledEventQueue.java --]
[-- Type: text/x-java; name="DisabledEventQueue.java", Size: 1383 bytes --]

// Tags: not-a-test

// Copyright (C) 2005 Roman Kennke <kennke@aicas.com>

// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version. 

// Mauve is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING.  If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.  */

package gnu.testlet.javax.swing.RepaintManager;

import java.awt.AWTEvent;
import java.awt.EventQueue;

/**
 * A special EventQueue used for testing purposes. It completely disables
 * dispatching of events, so the behaviour of the RepaintManager can be
 * examined more closely.
 *
 * @author Roman Kennke (kennke@aicas.com)
 */
public class DisabledEventQueue extends EventQueue
{
  /**
   * Overridden to do nothing.
   */
  protected void dispatchEvent(AWTEvent ev)
  {
    // Do nothing.
  }

  /**
   * Overridden to do nothing.
   */
  public void postEvent(AWTEvent ev)
  {
    // Do nothing.
  }
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-10-18 15:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-18 15:03 FYI: New RepaintManager test Roman Kennke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).