Skip to content

Commit

Permalink
Convert ProgressTestCase to pure JUnit 4
Browse files Browse the repository at this point in the history
Unstable test on MacOS verification build which should hopefully get a
bit more stable with "less" extra things being done by the tests.
  • Loading branch information
akurtakov committed Oct 25, 2024
1 parent 5c9af91 commit a9d76f0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2017 IBM Corporation and others.
* Copyright (c) 2009, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -15,6 +15,14 @@

package org.eclipse.ui.tests.progress;

import static org.eclipse.ui.tests.harness.util.UITestCase.processEvents;
import static org.eclipse.ui.tests.harness.util.UITestCase.processEventsUntil;
import static org.eclipse.ui.tests.harness.util.UITestCase.waitForJobs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
Expand All @@ -38,14 +46,7 @@
import org.eclipse.ui.progress.IProgressConstants2;
import org.eclipse.ui.tests.TestPlugin;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* @since 3.6
* @author Prakash G.R. ([email protected])
*/
@RunWith(JUnit4.class)

public class ProgressContantsTest extends ProgressTestCase {

/**
Expand All @@ -68,10 +69,6 @@ public boolean belongsTo(Object family) {
}
}

public ProgressContantsTest() {
super(ProgressContantsTest.class.getSimpleName());
}

@Test
public void testCommandProperty() throws Exception {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2019 IBM Corporation and others.
* Copyright (c) 2009, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -14,6 +14,9 @@

package org.eclipse.ui.tests.progress;

import static org.eclipse.ui.tests.harness.util.UITestCase.processEvents;
import static org.junit.Assert.assertNotNull;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

Expand All @@ -25,33 +28,31 @@
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.internal.progress.FinishedJobs;
import org.eclipse.ui.internal.progress.ProgressView;
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;

/**
* @since 3.6
*/
public abstract class ProgressTestCase extends UITestCase {
public abstract class ProgressTestCase {

protected ProgressView progressView;
protected IWorkbenchWindow window;

public ProgressTestCase(String testName) {
super(testName);
}
@Rule
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();

@Override
protected void doSetUp() throws Exception {
super.doSetUp();
window = openTestWindow("org.eclipse.ui.resourcePerspective");
@Before
public void doSetUp() throws Exception {
window = UITestCase.openTestWindow("org.eclipse.ui.resourcePerspective");

// Remove progress info items before running the tests to prevent random
// failings
FinishedJobs.getInstance().clearAll();
}

@Override
protected void doTearDown() throws Exception {
super.doTearDown();
@After
public void doTearDown() throws Exception {
// Remove progress info items
FinishedJobs.getInstance().clearAll();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

package org.eclipse.ui.tests.progress;

import static org.eclipse.ui.tests.harness.util.UITestCase.processEvents;
import static org.eclipse.ui.tests.harness.util.UITestCase.processEventsUntil;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -33,29 +37,22 @@
import org.eclipse.ui.internal.progress.TaskInfo;
import org.eclipse.ui.progress.IProgressConstants;
import org.eclipse.ui.tests.TestPlugin;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* @since 3.6
* @author Prakash G.R.
*/
@RunWith(JUnit4.class)
public class ProgressViewTests extends ProgressTestCase {

public ProgressViewTests() {
super(ProgressViewTests.class.getSimpleName());
}
public class ProgressViewTests extends ProgressTestCase {

@Override
protected void doSetUp() throws Exception {
@Before
public void doSetUp() throws Exception {
super.doSetUp();
FinishedJobs.getInstance().clearAll();
}

@Override
protected void doTearDown() throws Exception {
@After
public void doTearDown() throws Exception {
FinishedJobs.getInstance().clearAll();
super.doTearDown();
}
Expand Down

0 comments on commit a9d76f0

Please sign in to comment.