Author: tfmorris
Date: 2008-09-09 06:44:17-0700
New Revision: 15688
Modified:
trunk/src/argouml-app/tests/org/argouml/application/events/TestArgoEventPump.java
Log:
Issue 5368: Fix another test failure caused by changes to ArgoEventPump
Modified: trunk/src/argouml-app/tests/org/argouml/application/events/TestArgoEventPump.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/application/events/TestArgoEventPump.java?view=diff&rev=15688&p1=trunk/src/argouml-app/tests/org/argouml/application/events/TestArgoEventPump.java&p2=trunk/src/argouml-app/tests/org/argouml/application/events/TestArgoEventPump.java&r1=15687&r2=15688
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/application/events/TestArgoEventPump.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/application/events/TestArgoEventPump.java 2008-09-09 06:44:17-0700
@@ -24,6 +24,10 @@
package org.argouml.application.events;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.swing.SwingUtilities;
+
import junit.framework.TestCase;
/**
@@ -174,9 +178,24 @@
ArgoEventPump.fireEvent(evt);
// fire all of the diagram events
- evt = new ArgoDiagramAppearanceEvent(
+ final ArgoDiagramAppearanceEvent displayEvent =
+ new ArgoDiagramAppearanceEvent(
ArgoEventTypes.DIAGRAM_FONT_CHANGED, this);
- ArgoEventPump.fireEvent(evt);
+ try {
+ // Display events are fired on the Swing event thread.
+ // We need to wait for them to be dispatched
+ // NOTE: if more display events are added to this test, this one
+ // needs to be last
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ ArgoEventPump.fireEvent(displayEvent);
+ }
+ });
+ } catch (InterruptedException e) {
+ fail();
+ } catch (InvocationTargetException e) {
+ fail();
+ }
// fire all of the generator events
evt = new ArgoGeneratorEvent(ArgoEventTypes.GENERATOR_CHANGED, this);
@@ -204,9 +223,21 @@
evt = new ArgoNotationEvent(ArgoEventTypes.NOTATION_PROVIDER_ADDED,
this);
ArgoEventPump.fireEvent(evt);
- evt = new ArgoNotationEvent(ArgoEventTypes.NOTATION_PROVIDER_REMOVED,
- this);
- ArgoEventPump.fireEvent(evt);
+ final ArgoNotationEvent event = new ArgoNotationEvent(
+ ArgoEventTypes.NOTATION_PROVIDER_REMOVED, this);
+ try {
+ // Notation events are fired on the Swing event thread.
+ // We assume that serializing on the final call is sufficient
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ ArgoEventPump.fireEvent(event);
+ }
+ });
+ } catch (InterruptedException e) {
+ fail();
+ } catch (InvocationTargetException e) {
+ fail();
+ }
// fire all of the profile events
evt = new ArgoProfileEvent(ArgoEventTypes.PROFILE_ADDED, this);
@@ -321,8 +352,9 @@
int eventsFired = 0;
// counts each bit that has been fired
- for (int events = eventStatus; events > 0; ++eventsFired)
+ for (int events = eventStatus; events > 0; ++eventsFired) {
events &= events - 1;
+ }
return eventsFired;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.