Skip to content

Commit

Permalink
Cosmetic changes to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akurtakov committed Sep 11, 2024
1 parent 4461037 commit 0dcee1c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,9 @@ protected IProject provisionProject(String projectName) throws IOException, Core
}

@AfterEach
public void tearDown() throws CoreException {
public void tearDown() throws CoreException, IOException {
for (String projectName : this.provisionedProjects.keySet()) {
try {
getProject(projectName).delete(true, new NullProgressMonitor());
} catch (CoreException | IOException e) {
fail(e.getMessage());
}
getProject(projectName).delete(true, new NullProgressMonitor());
}
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,19 @@ static String getErrorPopupMessage() {

static IConsole getApplicationConsole(String binaryName) {
for (org.eclipse.ui.console.IConsole console : ConsolePlugin.getDefault().getConsoleManager().getConsoles()) {
if (console instanceof IConsole && ((IConsole) console).getProcess().getLabel().endsWith(binaryName)) {
return (IConsole) console;
if (console instanceof IConsole debugConsole && debugConsole.getProcess().getLabel().endsWith(binaryName)) {
return debugConsole;
}
}
return null;
}

static String findLabel(Composite composite) {
for (Control control : composite.getChildren()) {
if (control instanceof Label && !((Label) control).getText().isEmpty()) {
return ((Label) control).getText();
} else if (control instanceof Composite) {
return findLabel((Composite) control);
if (control instanceof Label l && !l.getText().isEmpty()) {
return l.getText();
} else if (control instanceof Composite c) {
return findLabel(c);
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void testExportProject() throws IOException, CoreException {
}

@Override
public void tearDown() throws CoreException {
public void tearDown() throws CoreException, IOException {
if (dialog != null) {
dialog.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.corrosion.tests;

import static org.junit.jupiter.api.Assertions.assertInstanceOf;

import java.io.IOException;

import org.eclipse.core.runtime.CoreException;
Expand All @@ -21,7 +23,6 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.genericeditor.ExtensionBasedTextEditor;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

Expand All @@ -34,7 +35,7 @@ void testEditorAssociation(String fileName) throws IOException, CoreException {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = null;
editor = IDE.openEditor(activePage, getProject(BASIC_PROJECT_NAME).getFile(fileName));
Assertions.assertTrue(editor instanceof ExtensionBasedTextEditor);
assertInstanceOf(ExtensionBasedTextEditor.class, editor);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -130,14 +129,10 @@ void testCreateNewProjectOutOfWorkspace() throws IOException {
}

@Override
public void tearDown() throws CoreException {
public void tearDown() throws CoreException, IOException {
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
if (!project.getName().equals(".cargo")) {
try {
project.delete(true, new NullProgressMonitor());
} catch (CoreException e) {
fail(e.getMessage());
}
project.delete(true, new NullProgressMonitor());
}
}
super.tearDown();
Expand Down

0 comments on commit 0dcee1c

Please sign in to comment.