From 2f628fcbe5c45282278cf36883b70ab5444640cc Mon Sep 17 00:00:00 2001 From: BobHanson Date: Mon, 23 Mar 2020 17:12:54 -0500 Subject: [PATCH] Bamboo test#12 adding flushEvents() --- src/jalview/viewmodel/ViewportRanges.java | 5 +++-- test/jalview/gui/SeqCanvasTest.java | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/jalview/viewmodel/ViewportRanges.java b/src/jalview/viewmodel/ViewportRanges.java index f42e730..51ee8d8 100644 --- a/src/jalview/viewmodel/ViewportRanges.java +++ b/src/jalview/viewmodel/ViewportRanges.java @@ -85,10 +85,10 @@ public class ViewportRanges extends ViewportProperties String st = Thread.currentThread().toString(); sTest += "ViewPortRanges.setEndseqTest " + val + " " + st + "\n"; - if (st.indexOf("Event") >= 0) + if (val == 13) { sTest += Arrays.toString(new NullPointerException().getStackTrace()) - .substring(0, 500) + .replace(',', '\n') + "\n"; } endSeq = val; @@ -227,6 +227,7 @@ public class ViewportRanges extends ViewportProperties * @param seq * sequence position */ + synchronized public void setStartSeq(int seq) { int height = getViewportHeight(); diff --git a/test/jalview/gui/SeqCanvasTest.java b/test/jalview/gui/SeqCanvasTest.java index 6f5fa2e..4e22348 100644 --- a/test/jalview/gui/SeqCanvasTest.java +++ b/test/jalview/gui/SeqCanvasTest.java @@ -31,6 +31,7 @@ import jalview.viewmodel.ViewportRanges; import java.awt.Font; import java.awt.FontMetrics; +import java.awt.Toolkit; import org.testng.Assert; import org.testng.annotations.BeforeClass; @@ -379,6 +380,8 @@ public class SeqCanvasTest @Test(groups = "Functional") public void testCalculateWrappedGeometry_fromScrolled() { + flushEvents(); + ViewportRanges.sTest = ""; Thread.currentThread().setName("SeqCanvasTest fromScrolled " + ++nTest); AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( "examples/uniref50.fa", DataSourceType.FILE); @@ -386,6 +389,7 @@ public class SeqCanvasTest AlignmentI al = av.getAlignment(); assertEquals(al.getWidth(), 157); assertEquals(al.getHeight(), 15); + flushEvents(); av.getRanges().setStartEndSeq(0, 3); String s = ""; s += " SC1 " + av.getRanges() + " " + ViewportRanges.sTest; @@ -408,4 +412,9 @@ public class SeqCanvasTest assertEquals(av.getRanges().getEndSeq(), 0, "endSeq should be 3 " + s); // unchanged assertEquals(repeatingHeight, charHeight * (2 + al.getHeight())); } + + private static void flushEvents() + { + ((sun.awt.SunToolkit) Toolkit.getDefaultToolkit()).flushPendingEvents(); + } } -- 1.7.10.2