Bug 515757 - Replace assertTrue with assertNull/NotNull in tests
Change-Id: If8d7b34eda66dc8951f0124628374c0534951367
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
index 53d4e4c..4e3ee3c 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
@@ -12,6 +12,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;
@@ -577,7 +579,7 @@
} catch (Exception e) {
fail("1) if javascript is dissabled, browser.evaluate() should return null. But an Exception was thrown");
}
- assertTrue("2) Javascript should not have executed. But not-null was returned:"+expectedNull, expectedNull == null);
+ assertNull("2) Javascript should not have executed. But not-null was returned:"+expectedNull, expectedNull);
testPassed.set(true);
testFinished.set(true);
@@ -620,7 +622,7 @@
pageLoadCount.set(3);
Boolean shouldBeNull = (Boolean) browser.evaluate("return true");
- assertTrue("1) Evaluate execution should be null, but 'true was returned'", shouldBeNull == null);
+ assertNull("1) Evaluate execution should be null, but 'true was returned'", shouldBeNull);
instanceOneFinishedCorrectly.set(true);
}
}
@@ -760,7 +762,7 @@
@Test
public void test_getUrl() {
String string = browser.getUrl();
- assertTrue(string != null);
+ assertNotNull(string);
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyleRange.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyleRange.java
index 746fae7..e6db877 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyleRange.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyleRange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +12,7 @@
package org.eclipse.swt.tests.junit;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.HashMap;
@@ -68,8 +69,8 @@
StyleRange styleRange = new StyleRange();
assertTrue(":a:", styleRange.start == 0);
assertTrue(":a:", styleRange.length == 0);
- assertTrue(":a:", styleRange.foreground == null);
- assertTrue(":a:", styleRange.background == null);
+ assertNull(":a:", styleRange.foreground);
+ assertNull(":a:", styleRange.background);
assertTrue(":a:", styleRange.fontStyle == SWT.NORMAL);
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
index 27edeb4..4ee7edf 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
@@ -15,6 +15,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -148,8 +149,8 @@
text.dispose();
text = new StyledText(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE);
- assertTrue(":b:", text.getVerticalBar() == null);
- assertTrue(":c:", text.getHorizontalBar() == null);
+ assertNull(":b:", text.getVerticalBar());
+ assertNull(":c:", text.getHorizontalBar());
text.dispose();
}
@@ -772,7 +773,7 @@
public void test_getContent() {
StyledTextContent content = text.getContent();
- assertTrue(content != null);
+ assertNotNull(content);
content = new StyledTextContent() {
@Override
public void addTextChangeListener(TextChangeListener listener) {
@@ -927,7 +928,7 @@
public void test_getLineBackgroundI() {
String textString = "L1\nL2\nL3\nL4";
text.setText(textString);
- assertTrue(":1:", text.getLineBackground(0) == null);
+ assertNull(":1:", text.getLineBackground(0));
text.setLineBackground(1,1,getColor(YELLOW));
text.setLineBackground(2,1,getColor(BLUE));
assertTrue(":1:", text.getLineBackground(1) == getColor(YELLOW));
@@ -1598,13 +1599,13 @@
}
@Test
public void test_getSelectionBackground() {
- assertTrue(":1:", text.getSelectionBackground() != null);
+ assertNotNull(":1:", text.getSelectionBackground());
text.setSelectionBackground(getColor(YELLOW));
assertTrue(":1:", text.getSelectionBackground() == getColor(YELLOW));
}
@Test
public void test_getSelectionForeground() {
- assertTrue(":1:", text.getSelectionForeground() != null);
+ assertNotNull(":1:", text.getSelectionForeground());
text.setSelectionForeground(getColor(RED));
assertTrue(":1:", text.getSelectionForeground() == getColor(RED));
}
@@ -3427,27 +3428,27 @@
text.setLineBackground(0,1,getColor(RED));
text.setLineBackground(1,1,getColor(YELLOW));
text.replaceTextRange(0,5,"");
- assertTrue(":0d1:", text.getLineBackground(0) == null);
+ assertNull(":0d1:", text.getLineBackground(0));
text.setText(textString);
text.setLineBackground(0,1,getColor(RED));
text.setLineBackground(1,1,getColor(YELLOW));
text.replaceTextRange(1,3,"");
assertTrue(":0e1:", text.getLineBackground(0) == getColor(RED));
- assertTrue(":0e1:", text.getLineBackground(1) == null);
+ assertNull(":0e1:", text.getLineBackground(1));
textString = "L1\nL2";
text.setText(textString);
text.setLineBackground(1,1,getColor(YELLOW));
text.replaceTextRange(1,4,"");
- assertTrue(":0f1:", text.getLineBackground(0) == null);
+ assertNull(":0f1:", text.getLineBackground(0));
text.setText(textString+"\n");
text.setLineBackground(0,1,getColor(RED));
text.setLineBackground(1,1,getColor(YELLOW));
text.replaceTextRange(0,6,"");
- assertTrue(":0g1:", text.getLineBackground(0) == null);
+ assertNull(":0g1:", text.getLineBackground(0));
text.setText(textString);
text.setLineBackground(0,0,getColor(RED));
- assertTrue(":1:", text.getLineBackground(0) == null);
+ assertNull(":1:", text.getLineBackground(0));
text.setLineBackground(0,1,getColor(RED));
assertTrue(":1:", text.getLineBackground(0) == getColor(RED));
@@ -3456,7 +3457,7 @@
text.setLineBackground(0,2,getColor(RED));
text.setLineBackground(2,2,getColor(YELLOW));
text.replaceTextRange(0,0,"\n");
- assertTrue(":2:", text.getLineBackground(0) == null);
+ assertNull(":2:", text.getLineBackground(0));
assertTrue(":2:", text.getLineBackground(1) == getColor(RED));
assertTrue(":2:", text.getLineBackground(2) == getColor(RED));
assertTrue(":2:", text.getLineBackground(3) == getColor(YELLOW));
@@ -3475,17 +3476,17 @@
text.setLineBackground(0,1,getColor(RED));
text.setLineBackground(2,1,getColor(YELLOW));
text.replaceTextRange(0,18,"");
- assertTrue(":4:", text.getLineBackground(0) == null);
+ assertNull(":4:", text.getLineBackground(0));
textString = "Line1\nLine2\nLine3\nLine4";
text.setText(textString);
text.setLineBackground(0,1,getColor(RED));
text.setLineBackground(2,1,getColor(YELLOW));
text.replaceTextRange(0,18,"L1\nL2\nL3\n");
- assertTrue(":5:", text.getLineBackground(0) == null);
- assertTrue(":5:", text.getLineBackground(1) == null);
- assertTrue(":5:", text.getLineBackground(2) == null);
- assertTrue(":5:", text.getLineBackground(3) == null);
+ assertNull(":5:", text.getLineBackground(0));
+ assertNull(":5:", text.getLineBackground(1));
+ assertNull(":5:", text.getLineBackground(2));
+ assertNull(":5:", text.getLineBackground(3));
textString = "Line1\nLine2\nLine3\nLine4";
text.setText(textString);
@@ -3495,7 +3496,7 @@
text.setLineBackground(3,1,getColor(GREEN));
text.replaceTextRange(3,9,"L1\nL2\n");
assertTrue(":6a:", text.getLineBackground(0) == getColor(RED));
- assertTrue(":6a:", text.getLineBackground(1) == null);
+ assertNull(":6a:", text.getLineBackground(1));
textString = "Line1\nLine2\nLine3\nLine4";
text.setText(textString);
text.setLineBackground(0,1,getColor(RED));
@@ -3503,8 +3504,8 @@
text.setLineBackground(2,1,getColor(BLUE));
text.setLineBackground(3,1,getColor(GREEN));
text.replaceTextRange(11,11,"L3\nL4");
- assertTrue(":6b:", text.getLineBackground(2) == null);
- assertTrue(":6b:", text.getLineBackground(3) == null);
+ assertNull(":6b:", text.getLineBackground(2));
+ assertNull(":6b:", text.getLineBackground(3));
textString = "Line1\nLine2\nLine3\nLine4";
text.setText(textString);
@@ -3513,7 +3514,7 @@
text.setLineBackground(2,1,getColor(BLUE));
text.setLineBackground(3,1,getColor(GREEN));
text.replaceTextRange(0,18,"L1\n");
- assertTrue(":7:", text.getLineBackground(0) == null);
+ assertNull(":7:", text.getLineBackground(0));
assertTrue(":7:", text.getLineBackground(1) == getColor(GREEN));
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_ColorDialog.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_ColorDialog.java
index 0b64076..698625d 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_ColorDialog.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_ColorDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,7 @@
package org.eclipse.swt.tests.junit;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -65,12 +66,12 @@
public void test_setRGBLorg_eclipse_swt_graphics_RGB() {
RGB rgb = new RGB(0, 0, 0);
- assertTrue(":a:", colorDialog.getRGB() == null);
+ assertNull(":a:", colorDialog.getRGB());
colorDialog.setRGB(rgb);
assertTrue(":b:", colorDialog.getRGB() == rgb);
colorDialog.setRGB(null);
- assertTrue(":c:", colorDialog.getRGB() == null);
+ assertNull(":c:", colorDialog.getRGB());
}
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
index 181b56a..d903560 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
@@ -327,7 +327,7 @@
@Test
public void test_getAccessible() {
Accessible accessible = control.getAccessible();
- assertTrue(":a:", accessible != null);
+ assertNotNull(":a:", accessible);
}
@Test
public void test_getBorderWidth() {
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Decorations.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Decorations.java
index e448e8f..4635a12 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Decorations.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Decorations.java
@@ -85,7 +85,7 @@
@Test
public void test_getMenuBar() {
- assertTrue(":a:", decorations.getMenuBar() == null);
+ assertNull(":a:", decorations.getMenuBar());
Menu bar = new Menu (decorations, SWT.BAR);
decorations.setMenuBar (bar);
assertTrue(":b:", decorations.getMenuBar() == bar);
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
index ccbf435..8f1cfcb 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -359,7 +359,7 @@
assertNotNull(monitors);
assertTrue("at least one monitor should be returned", monitors.length >= 1);
for (int i = 0; i < monitors.length; i++)
- assertTrue("monitor at index "+i+" should not be null", monitors[i] != null);
+ assertNotNull("monitor at index "+i+" should not be null", monitors[i]);
display.dispose();
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_FileDialog.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_FileDialog.java
index cad5f35..a057bf3 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_FileDialog.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_FileDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.tests.junit;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -93,7 +94,7 @@
assertTrue(name.isEmpty());
fileDialog.setFileName(null);
name = fileDialog.getFileName();
- assertTrue(name==null);
+ assertNull(name);
fileDialog.setFileName("somefile.test");
name = fileDialog.getFileName();
assertTrue(name.equals("somefile.test"));
@@ -111,7 +112,7 @@
assertTrue(filters.length == 1);
fileDialog.setFilterExtensions(null);
filters = fileDialog.getFilterExtensions();
- assertTrue(filters==null);
+ assertNull(filters);
}
@Test
@@ -126,7 +127,7 @@
assertTrue(filters.length == 1);
fileDialog.setFilterNames(null);
filters = fileDialog.getFilterNames();
- assertTrue(filters==null);
+ assertNull(filters);
}
@Test
@@ -138,7 +139,7 @@
fileDialog.setFilterPath("");
assertTrue(":3:", fileDialog.getFilterPath().isEmpty());
fileDialog.setFilterPath(null);
- assertTrue(":4:", fileDialog.getFilterPath() == null);
+ assertNull(":4:", fileDialog.getFilterPath());
}
/* custom */
FileDialog fileDialog;
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Shell.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Shell.java
index 9bd8b40..f2d5e9e 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Shell.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Shell.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -318,7 +319,7 @@
@Test
public void test_getParent () {
// overriding Control.test_getParent
- assertTrue(shell.getParent()==null);
+ assertNull(shell.getParent());
assertTrue(testShell.getParent() == shell);
}
@@ -434,21 +435,21 @@
Region region = new Region();
region.add(new Rectangle(10, 20, 100, 200));
// test shell without style SWT.NO_TRIM
- assertTrue(":a:", shell.getRegion() == null);
+ assertNull(":a:", shell.getRegion());
shell.setRegion(region);
- assertTrue(":b:", shell.getRegion() == null);
+ assertNull(":b:", shell.getRegion());
shell.setRegion(null);
- assertTrue(":c:", shell.getRegion() == null);
+ assertNull(":c:", shell.getRegion());
// test shell with style SWT.NO_TRIM
Display display = shell.getDisplay();
Shell shell2 = new Shell(display, SWT.NO_TRIM);
- assertTrue(":d:", shell2.getRegion() == null);
+ assertNull(":d:", shell2.getRegion());
shell2.setRegion(region);
assertTrue(":e:", shell2.getRegion().handle == region.handle);
region.dispose();
assertTrue(":f:", shell2.getRegion().isDisposed());
shell2.setRegion(null);
- assertTrue(":g:", shell2.getRegion() == null);
+ assertNull(":g:", shell2.getRegion());
}
@Override
@Test
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_TabItem.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_TabItem.java
index 4f8708a..9901609 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_TabItem.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_TabItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,7 @@
package org.eclipse.swt.tests.junit;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -95,13 +96,13 @@
public void test_setControlLorg_eclipse_swt_widgets_Control() {
Control control = new Table(tabFolder, SWT.NULL);
- assertTrue(":a: ", tabItem.getControl() == null);
+ assertNull(":a: ", tabItem.getControl());
tabItem.setControl(control);
assertTrue(":b: ", tabItem.getControl() == control);
tabItem.setControl(null);
- assertTrue(":c: ", tabItem.getControl() == null);
+ assertNull(":c: ", tabItem.getControl());
}
@Override
@@ -121,7 +122,7 @@
tabItem.setToolTipText("fredttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt");
assertTrue(":b: ", tabItem.getToolTipText().equals("fredttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt"));
tabItem.setToolTipText(null);
- assertTrue(":c: ", tabItem.getToolTipText() == null);
+ assertNull(":c: ", tabItem.getToolTipText());
}
/* custom */