| Index: editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/AbstractDartTest.java
|
| diff --git a/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/RefactoringTest.java b/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/AbstractDartTest.java
|
| similarity index 78%
|
| copy from editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/RefactoringTest.java
|
| copy to editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/AbstractDartTest.java
|
| index cd3d5e4a2996eb2bd77cadd1ed89cd859a266b03..41772486af45176047020c643341a08474e843a7 100644
|
| --- a/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/RefactoringTest.java
|
| +++ b/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/AbstractDartTest.java
|
| @@ -15,26 +15,45 @@ package com.google.dart.tools.ui.refactoring;
|
|
|
| import com.google.common.base.Joiner;
|
| import com.google.common.base.Splitter;
|
| -import com.google.common.collect.Lists;
|
| import com.google.dart.tools.core.model.CompilationUnit;
|
| import com.google.dart.tools.core.model.DartElement;
|
| import com.google.dart.tools.core.test.util.TestProject;
|
| -import com.google.dart.tools.ui.internal.refactoring.UserInteractions;
|
|
|
| import junit.framework.TestCase;
|
|
|
| -import org.eclipse.core.runtime.IStatus;
|
| -import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
| -import org.eclipse.swt.widgets.Shell;
|
| +import org.eclipse.swt.widgets.Display;
|
|
|
| import static org.fest.assertions.Assertions.assertThat;
|
|
|
| -import java.util.List;
|
| -
|
| /**
|
| - * Abstract test for any refactoring.
|
| + * Abstract base for any Dart test which uses {@link TestProject}.
|
| */
|
| -public abstract class RefactoringTest extends TestCase {
|
| +public abstract class AbstractDartTest extends TestCase {
|
| + /**
|
| + * Waits given number of milliseconds and runs events loop every 1 millisecond. At least one
|
| + * events loop will be executed.
|
| + */
|
| + public static void waitEventLoop(int time) {
|
| + waitEventLoop(time, 0);
|
| + }
|
| +
|
| + /**
|
| + * Waits given number of milliseconds and runs events loop every <code>sleepMillis</code>
|
| + * milliseconds. At least one events loop will be executed.
|
| + */
|
| + public static void waitEventLoop(int time, long sleepMillis) {
|
| + long start = System.currentTimeMillis();
|
| + do {
|
| + try {
|
| + Thread.sleep(sleepMillis);
|
| + } catch (Throwable e) {
|
| + }
|
| + while (Display.getCurrent().readAndDispatch()) {
|
| + // do nothing
|
| + }
|
| + } while (System.currentTimeMillis() - start < time);
|
| + }
|
| +
|
| /**
|
| * Asserts that {@link CompilationUnit} has expected content.
|
| */
|
| @@ -89,12 +108,6 @@ public abstract class RefactoringTest extends TestCase {
|
| System.out.println(getLinesForSource(lines));
|
| }
|
|
|
| - protected final List<String> openInformationMessages = Lists.newArrayList();
|
| -
|
| - protected final List<String> showStatusMessages = Lists.newArrayList();
|
| -
|
| - protected boolean showStatusCancel;
|
| -
|
| protected TestProject testProject;
|
|
|
| protected CompilationUnit testUnit;
|
| @@ -140,25 +153,10 @@ public abstract class RefactoringTest extends TestCase {
|
| @Override
|
| protected void setUp() throws Exception {
|
| testProject = new TestProject();
|
| - UserInteractions.openInformation = new UserInteractions.OpenInformation() {
|
| - @Override
|
| - public void open(Shell parent, String title, String message) {
|
| - openInformationMessages.add(message);
|
| - }
|
| - };
|
| - UserInteractions.showStatusDialog = new UserInteractions.ShowStatusDialog() {
|
| - @Override
|
| - public boolean open(RefactoringStatus status, Shell parent, String windowTitle) {
|
| - showStatusMessages.add(status.getMessageMatchingSeverity(IStatus.INFO));
|
| - return showStatusCancel;
|
| - }
|
| - };
|
| - showStatusCancel = true;
|
| }
|
|
|
| @Override
|
| protected void tearDown() throws Exception {
|
| - UserInteractions.reset();
|
| testProject.dispose();
|
| testProject = null;
|
| }
|
|
|