summaryrefslogtreecommitdiff
path: root/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestEvaluationCallback.java
blob: cb1b18e3795ab9c66b8d0547d55a0d9bc102102e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.intellij.xdebugger;

import com.intellij.openapi.util.Pair;
import com.intellij.xdebugger.frame.XValue;
import junit.framework.Assert;
import org.jetbrains.annotations.NotNull;

import java.util.concurrent.Semaphore;

public class XTestEvaluationCallback extends com.intellij.xdebugger.impl.ui.tree.nodes.XEvaluationCallbackBase {
  private XValue myResult;
  private String myErrorMessage;
  private final Semaphore myFinished = new Semaphore(0);

  @Override
  public void evaluated(@NotNull XValue result) {
    myResult = result;
    myFinished.release();
  }

  @Override
  public void errorOccurred(@NotNull String errorMessage) {
    myErrorMessage = errorMessage;
    myFinished.release();
  }

  public Pair<XValue, String> waitFor(long timeoutInMilliseconds) throws InterruptedException {
    Assert.assertTrue("timed out", XDebuggerTestUtil.waitFor(myFinished, timeoutInMilliseconds));
    return Pair.create(myResult, myErrorMessage);
  }
}