Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
*******************************************************************************/
package org.eclipse.swt.tests.junit;

import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.eclipse.swt.SWT;
import org.eclipse.swt.printing.PrintDialog;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Automated Test Suite for class org.eclipse.swt.printing.PrintDialog
Expand All @@ -28,7 +28,7 @@
public class Test_org_eclipse_swt_printing_PrintDialog extends Test_org_eclipse_swt_widgets_Dialog {

@Override
@Before
@BeforeEach
public void setUp() {
super.setUp();
printDialog = new PrintDialog(shell, SWT.NONE);
Expand All @@ -39,24 +39,14 @@ public void setUp() {
public void test_ConstructorLorg_eclipse_swt_widgets_Shell() {
new PrintDialog(shell);

try {
new PrintDialog(null);
fail("No exception thrown for parent == null");
}
catch (IllegalArgumentException e) {
}
assertThrows(IllegalArgumentException.class, () -> new PrintDialog(null),"No exception thrown for parent == null");
}

@Test
public void test_ConstructorLorg_eclipse_swt_widgets_ShellI() {
new PrintDialog(shell, SWT.NONE);

try {
new PrintDialog(null, SWT.NONE);
fail("No exception thrown for parent == null");
}
catch (IllegalArgumentException e) {
}
assertThrows(IllegalArgumentException.class, () -> new PrintDialog(null, SWT.NONE),"No exception thrown for parent == null");
}

/* custom */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
*******************************************************************************/
package org.eclipse.swt.tests.junit;


import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.ColorDialog;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Automated Test Suite for class org.eclipse.swt.widgets.ColorDialog
Expand All @@ -34,7 +33,7 @@ public class Test_org_eclipse_swt_widgets_ColorDialog extends Test_org_eclipse_s
ColorDialog colorDialog;

@Override
@Before
@BeforeEach
public void setUp() {
super.setUp();
colorDialog = new ColorDialog(shell, SWT.NULL);
Expand All @@ -45,36 +44,26 @@ public void setUp() {
public void test_ConstructorLorg_eclipse_swt_widgets_Shell() {
new ColorDialog(shell);

try {
new ColorDialog(null);
fail("No exception thrown for parent == null");
}
catch (IllegalArgumentException e) {
}
assertThrows(IllegalArgumentException.class,()-> new ColorDialog(null),"No exception thrown for parent == null");
}

@Test
public void test_ConstructorLorg_eclipse_swt_widgets_ShellI() {
new ColorDialog(shell, SWT.NULL);

try {
new ColorDialog(null, SWT.NULL);
fail("No exception thrown for parent == null");
}
catch (IllegalArgumentException e) {
}
assertThrows(IllegalArgumentException.class,()-> new ColorDialog(null, SWT.NULL),"No exception thrown for parent == null");
}

@Test
public void test_setRGBLorg_eclipse_swt_graphics_RGB() {
RGB rgb = new RGB(0, 0, 0);

assertNull(":a:", colorDialog.getRGB());
assertNull(colorDialog.getRGB());

colorDialog.setRGB(rgb);
assertTrue(":b:", colorDialog.getRGB() == rgb);
assertTrue(colorDialog.getRGB() == rgb);

colorDialog.setRGB(null);
assertNull(":c:", colorDialog.getRGB());
assertNull(colorDialog.getRGB());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
*******************************************************************************/
package org.eclipse.swt.tests.junit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Shell;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Automated Test Suite for class org.eclipse.swt.widgets.Dialog
Expand All @@ -30,19 +30,19 @@
*/
public class Test_org_eclipse_swt_widgets_Dialog {

@Before
@BeforeEach
public void setUp() {
shell = new Shell();
}

@After
@AfterEach
public void tearDown() {
shell.dispose();
}

@Test
public void test_getParent() {
assertTrue(":a:", dialog.getParent() == shell);
assertTrue(dialog.getParent() == shell);
}

@Test
Expand All @@ -54,18 +54,13 @@ public void test_getStyle() {

@Test
public void test_setTextLjava_lang_String() {
assertTrue(":1:", dialog.getText() == "");
assertTrue(dialog.getText() == "");
String testStr = "test string";
dialog.setText(testStr);
assertEquals(":2:", testStr, dialog.getText());
assertEquals(testStr, dialog.getText());
dialog.setText("");
assertTrue(":3:", dialog.getText().isEmpty());
try {
dialog.setText(null);
fail("No exception thrown for string = null");
}
catch (IllegalArgumentException e) {
}
assertTrue(dialog.getText().isEmpty());
assertThrows(IllegalArgumentException.class, () -> dialog.setText(null), "No exception thrown for string = null");
}

/* custom */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
*******************************************************************************/
package org.eclipse.swt.tests.junit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Automated Test Suite for class org.eclipse.swt.widgets.DirectoryDialog
Expand All @@ -31,7 +31,7 @@
public class Test_org_eclipse_swt_widgets_DirectoryDialog extends Test_org_eclipse_swt_widgets_Dialog {

@Override
@Before
@BeforeEach
public void setUp() {
super.setUp();
dirDialog = new DirectoryDialog(shell, SWT.NULL);
Expand All @@ -41,12 +41,7 @@ public void setUp() {
@Test
public void test_ConstructorLorg_eclipse_swt_widgets_Shell() {
new DirectoryDialog(shell);
try {
new DirectoryDialog(null);
fail("No exception thrown for null parent");
}
catch (IllegalArgumentException e) {
}
assertThrows(IllegalArgumentException.class,()-> new DirectoryDialog(null),"No exception thrown for null parent");
}

@Test
Expand All @@ -57,29 +52,25 @@ public void test_open() {

@Test
public void test_setFilterPathLjava_lang_String() {
assertTrue(":1:", dirDialog.getFilterPath() == "");
assertTrue(dirDialog.getFilterPath() == "");
String testStr = "./*";
dirDialog.setFilterPath(testStr);
assertEquals(":2:", testStr, dirDialog.getFilterPath());
assertEquals(testStr, dirDialog.getFilterPath());
dirDialog.setFilterPath("");
assertTrue(":3:", dirDialog.getFilterPath().isEmpty());
assertTrue(dirDialog.getFilterPath().isEmpty());
dirDialog.setFilterPath(null);
assertNull(":4:", dirDialog.getFilterPath());
assertNull(dirDialog.getFilterPath());
}

@Test
public void test_setMessageLjava_lang_String() {
assertTrue(":1:", dirDialog.getMessage() == "");
assertTrue( dirDialog.getMessage() == "");
String testStr = "test string";
dirDialog.setMessage(testStr);
assertEquals(":2:", testStr, dirDialog.getMessage());
assertEquals(testStr, dirDialog.getMessage());
dirDialog.setMessage("");
assertTrue(":3:", dirDialog.getMessage().isEmpty());
try {
dirDialog.setMessage(null);
fail ("null argument did not throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
}
assertTrue(dirDialog.getMessage().isEmpty());
assertThrows(IllegalArgumentException.class,()->dirDialog.setMessage(null),"null argument did not throw IllegalArgumentException");
}

/* custom */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
*******************************************************************************/
package org.eclipse.swt.tests.junit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Automated Test Suite for class org.eclipse.swt.widgets.FileDialog
Expand All @@ -31,7 +31,7 @@
public class Test_org_eclipse_swt_widgets_FileDialog extends Test_org_eclipse_swt_widgets_Dialog {

@Override
@Before
@BeforeEach
public void setUp() {
super.setUp();
fileDialog = new FileDialog(shell, SWT.NULL);
Expand All @@ -42,12 +42,7 @@ public void setUp() {
public void test_ConstructorLorg_eclipse_swt_widgets_Shell() {
// Test FileDialog(Shell)
new FileDialog(shell);
try {
new FileDialog(null);
fail("No exception thrown for parent == null");
}
catch (IllegalArgumentException e) {
}
assertThrows(IllegalArgumentException.class,()-> new FileDialog(null),"No exception thrown for parent == null");
}

@Test
Expand Down Expand Up @@ -136,14 +131,14 @@ public void test_setFileNameLjava_lang_String() {

@Test
public void test_setFilterPathLjava_lang_String() {
assertEquals(":1:", "", fileDialog.getFilterPath());
assertEquals("", fileDialog.getFilterPath());
String testStr = "./*";
fileDialog.setFilterPath(testStr);
assertEquals(":2:", testStr, fileDialog.getFilterPath());
assertEquals(testStr, fileDialog.getFilterPath());
fileDialog.setFilterPath("");
assertTrue(":3:", fileDialog.getFilterPath().isEmpty());
assertTrue(fileDialog.getFilterPath().isEmpty());
fileDialog.setFilterPath(null);
assertNull(":4:", fileDialog.getFilterPath());
assertNull(fileDialog.getFilterPath());
}
/* custom */
FileDialog fileDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
*******************************************************************************/
package org.eclipse.swt.tests.junit;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.FontDialog;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Automated Test Suite for class org.eclipse.swt.widgets.FontDialog
Expand All @@ -33,7 +33,7 @@
public class Test_org_eclipse_swt_widgets_FontDialog extends Test_org_eclipse_swt_widgets_Dialog {

@Override
@Before
@BeforeEach
public void setUp() {
super.setUp();
fontDialog = new FontDialog(shell, SWT.NULL);
Expand All @@ -43,22 +43,12 @@ public void setUp() {
@Test
public void test_ConstructorLorg_eclipse_swt_widgets_Shell() {
new FontDialog(shell);
try {
new FontDialog(null);
fail("No exception thrown for parent == null");
}
catch (IllegalArgumentException e) {
}
assertThrows(IllegalArgumentException.class,()-> new FontDialog(null),"No exception thrown for parent == null");
}

@Test
public void test_ConstructorLorg_eclipse_swt_widgets_ShellI() {
try {
new FontDialog(null, SWT.NULL);
fail("No exception thrown for parent == null");
}
catch (IllegalArgumentException e) {
}
assertThrows(IllegalArgumentException.class,()-> new FontDialog(null, SWT.NULL),"No exception thrown for parent == null");
}

@Test
Expand Down
Loading
Loading