Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gheorghe2013-09-12 12:04:22 -0400
committerBogdan Gheorghe2013-09-12 12:04:22 -0400
commit2527982ac068176e33d2c5edefd4e2394a3a98cc (patch)
treef49f549fac1e6c3bac2aeba734c679e29febbf2b
parent6350427271e30cbd3731a00deddf1a1c7533abaf (diff)
downloadeclipse.platform.swt-2527982ac068176e33d2c5edefd4e2394a3a98cc.tar.gz
eclipse.platform.swt-2527982ac068176e33d2c5edefd4e2394a3a98cc.tar.xz
eclipse.platform.swt-2527982ac068176e33d2c5edefd4e2394a3a98cc.zip
Fix test for Bug 360052 - New API for monitoring UI delays
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java41
1 files changed, 16 insertions, 25 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
index b0ff1dbb89..0148707bc1 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
@@ -23,7 +23,6 @@ import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.ILongEventWatchdog;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
@@ -801,26 +800,24 @@ public void test_LongEventWatchdog() {
try {
final boolean[] beginCalled = {false};
- final boolean[] eventSent = {false};
final boolean[] endCalled = {false};
final boolean[] eventHasRun = {false};
- ILongEventWatchdog callback = new ILongEventWatchdog() {
- public void beginEvent(int depth) {
+ Listener preListener = new Listener() {
+ public void handleEvent(Event event) {
beginCalled[0] = true;
}
-
- public void onLongEvent(LongEventInfo event) {
- eventSent[0] = true;
- }
-
- public void endEvent(int depth) {
+ };
+
+ Listener postListener = new Listener() {
+ public void handleEvent(Event event) {
endCalled[0] = true;
}
};
-
- display.getSynchronizer().registerLongDispatchWatchdogCallback(callback, DURATION_MILLIS);
-
+
+ display.addListener(SWT.PreEvent, preListener);
+ display.addListener(SWT.PostEvent, postListener);
+
display.asyncExec(new Runnable() {
public void run() {
try {
@@ -832,19 +829,13 @@ public void test_LongEventWatchdog() {
}
});
- // Detect falling edge of readAndDispatch's return value. It must always go high at least
- // once for the runnable this test asyncExec'd.
- boolean prevMoreToDispatch = false;
- boolean moreToDispatch = false;
-
- while (!eventHasRun[0] && !(prevMoreToDispatch && !moreToDispatch)) {
- prevMoreToDispatch = moreToDispatch;
- moreToDispatch = display.readAndDispatch();
- assertTrue(beginCalled[0] == endCalled[0]);
- assertTrue(!eventHasRun[0] || eventSent[0]); // eventHasRun[0] -> eventSent[0]
+ while (display.readAndDispatch()) {
}
-
- display.getSynchronizer().unregisterLongDispatchWatchdogCallback(callback);
+
+ display.removeListener(SWT.PreEvent, preListener);
+ display.removeListener(SWT.PostEvent, preListener);
+
+
assertTrue(beginCalled[0] && endCalled[0] && eventHasRun[0]);
} finally {
display.dispose();

Back to the top