diff options
author | Joel Majano | 2021-11-10 15:09:13 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2021-11-12 16:31:21 +0000 |
commit | b240238a37fe012ae27bddc96b9ae20c3c3dacf7 (patch) | |
tree | 2d036b9c072f63671cf3e849ad43531b30d81cce | |
parent | 5bc16a4edfbe915f6bf0254ffa1a1669f39d3297 (diff) | |
download | eclipse.platform.swt-b240238a37fe012ae27bddc96b9ae20c3c3dacf7.tar.gz eclipse.platform.swt-b240238a37fe012ae27bddc96b9ae20c3c3dacf7.tar.xz eclipse.platform.swt-b240238a37fe012ae27bddc96b9ae20c3c3dacf7.zip |
Junit streamlining - Set 2
More assert changes.
Change-Id: If8b89722e47a653c70bbef41e26802edf2e28f1d
Signed-off-by: Joel Majano <jmajano@redhat.com>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/187596
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
4 files changed, 35 insertions, 30 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Font.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Font.java index 237d3d94ed..d186e3431c 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Font.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Font.java @@ -17,6 +17,7 @@ package org.eclipse.swt.tests.junit; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -330,7 +331,7 @@ public void test_hashCode() { assertEquals(font,font); assertEquals(font.hashCode(),font.hashCode()); Font boldFont = new Font(display, SwtTestUtil.testFontName, 10, SWT.BOLD); - assertFalse(font.hashCode() == boldFont.hashCode()); + assertNotEquals(boldFont.hashCode(), font.hashCode()); boldFont.dispose(); font.dispose(); } diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_FontData.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_FontData.java index f047756b61..d5f1b1181b 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_FontData.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_FontData.java @@ -15,7 +15,7 @@ package org.eclipse.swt.tests.junit; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -104,7 +104,7 @@ public void test_hashCode() { assertEquals(fd1,fd2); assertEquals(fd1.hashCode(),fd2.hashCode()); FontData fd3 = new FontData(SwtTestUtil.testFontName, 10, SWT.BOLD); - assertFalse(fd1.hashCode() == fd3.hashCode()); + assertNotEquals(fd3.hashCode(), fd1.hashCode()); } @Test diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java index 0246b425d3..aa13464d7d 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java @@ -17,6 +17,7 @@ package org.eclipse.swt.tests.junit; import static org.eclipse.swt.tests.junit.SwtTestUtil.assertSWTProblem; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -465,23 +466,23 @@ public void test_getStyle() { Canvas canvas = new Canvas(shell, SWT.NULL); GC testGC = new GC(canvas, SWT.LEFT_TO_RIGHT); int style = testGC.getStyle(); - assertTrue((style & SWT.LEFT_TO_RIGHT) != 0); + assertNotEquals(0, (style & SWT.LEFT_TO_RIGHT)); testGC.dispose(); testGC = new GC(canvas); style = testGC.getStyle(); - assertTrue((style & SWT.LEFT_TO_RIGHT) != 0); + assertNotEquals(0, (style & SWT.LEFT_TO_RIGHT)); testGC.dispose(); testGC = new GC(canvas, SWT.RIGHT_TO_LEFT); style = testGC.getStyle(); - assertTrue((style & SWT.RIGHT_TO_LEFT) != 0); + assertNotEquals(0, (style & SWT.RIGHT_TO_LEFT)); testGC.dispose(); } @Test public void test_hashCode() { - assertTrue(gc.hashCode() == gc.hashCode()); + assertEquals(gc.hashCode(), gc.hashCode()); GC gc2 = new GC(shell); - assertFalse(gc.hashCode() == gc2.hashCode()); + assertNotEquals(gc2.hashCode(), gc.hashCode()); gc2.dispose(); } @@ -560,7 +561,7 @@ public void test_setClippingLorg_eclipse_swt_graphics_Rectangle() { public void test_setFontLorg_eclipse_swt_graphics_Font() { gc.setFont(shell.getDisplay().getSystemFont()); Font font = gc.getFont(); - assertTrue(font.equals(shell.getDisplay().getSystemFont())); + assertEquals(shell.getDisplay().getSystemFont(), font); } @Test @@ -585,23 +586,23 @@ public void test_setForegroundLorg_eclipse_swt_graphics_Color() { @Test public void test_setLineStyleI() { gc.setLineStyle(SWT.LINE_SOLID); - assertTrue(gc.getLineStyle() == SWT.LINE_SOLID); + assertEquals(SWT.LINE_SOLID, gc.getLineStyle()); gc.setLineStyle(SWT.LINE_DASH); - assertTrue(gc.getLineStyle() == SWT.LINE_DASH); + assertEquals(SWT.LINE_DASH, gc.getLineStyle()); gc.setLineStyle(SWT.LINE_DOT); - assertTrue(gc.getLineStyle() == SWT.LINE_DOT); + assertEquals(SWT.LINE_DOT, gc.getLineStyle()); gc.setLineStyle(SWT.LINE_DASHDOT); - assertTrue(gc.getLineStyle() == SWT.LINE_DASHDOT); + assertEquals(SWT.LINE_DASHDOT, gc.getLineStyle()); gc.setLineStyle(SWT.LINE_DASHDOTDOT); - assertTrue(gc.getLineStyle() == SWT.LINE_DASHDOTDOT); + assertEquals(SWT.LINE_DASHDOTDOT, gc.getLineStyle()); } @Test public void test_setLineWidthI() { gc.setLineWidth(10); - assertTrue(gc.getLineWidth() == 10); + assertEquals(10, gc.getLineWidth()); gc.setLineWidth(0); - assertTrue(gc.getLineWidth() == 0); + assertEquals(0, gc.getLineWidth()); } @Test diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Button.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Button.java index e0d35c60fb..615d9437de 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Button.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Button.java @@ -15,6 +15,7 @@ package org.eclipse.swt.tests.junit; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -157,7 +158,8 @@ public void test_setAlignmentI() { assertEquals(SWT.CENTER, button.getAlignment()); button.setAlignment(SWT.UP); // bad value for push button - assertTrue(SWT.UP != button.getAlignment()); + assertNotEquals(SWT.UP, button.getAlignment()); + Button arrowButton = new Button(shell, SWT.ARROW); arrowButton.setAlignment(SWT.LEFT); @@ -173,12 +175,12 @@ public void test_setAlignmentI() { assertEquals(SWT.DOWN, arrowButton.getAlignment()); arrowButton.setAlignment(SWT.CENTER); // bad value for arrow button - assertTrue(SWT.CENTER != arrowButton.getAlignment()); + assertNotEquals(SWT.CENTER, arrowButton.getAlignment()); arrowButton.dispose(); int alignment = 55; // some bogus number button.setAlignment(alignment); - assertTrue(alignment != button.getAlignment()); + assertNotEquals(alignment, button.getAlignment()); } @Test @@ -189,15 +191,16 @@ public void test_setBackgroundCheckButton() { assertEquals("getBackground not equal after setBackground for SWT.CHECK Button", color, checkButton.getBackground()); checkButton.setBackground(null); - assertTrue("getBackground unchanged after setBackground(null) for SWT.CHECK Button", - !checkButton.getBackground().equals(color)); + assertNotEquals("getBackground unchanged after setBackground(null) for SWT.CHECK Button", + color, checkButton.getBackground()); + color = new Color(255, 0, 0, 0); checkButton.setBackground(color); assertEquals("getBackground not equal after setBackground with 0 alpha for SWT.CHECK Button", color, checkButton.getBackground()); checkButton.setBackground(null); - assertTrue("getBackground unchanged after setBackground(null) with 0 alpha for SWT.CHECK Button", - !checkButton.getBackground().equals(color)); + assertNotEquals("getBackground unchanged after setBackground(null) with 0 alpha for SWT.CHECK Button", + color, checkButton.getBackground()); if ("gtk".equals(SWT.getPlatform ())) { Color fg = new Color(0, 255, 0); checkButton.setBackground(color); @@ -230,15 +233,15 @@ public void test_setBackgroundRadioButton() { assertEquals("getBackground not equal after setBackground for SWT.RADIO Button", color, radioButton.getBackground()); radioButton.setBackground(null); - assertFalse("getBackground unchanged after setBackground(null) for SWT.RADIO Button", - radioButton.getBackground().equals(color)); + assertNotEquals("getBackground unchanged after setBackground(null) for SWT.RADIO Button", + color, radioButton.getBackground()); color = new Color(255, 0, 0, 0); radioButton.setBackground(color); assertEquals("getBackground not equal after setBackground with 0 alpha for SWT.RADIO Button", color, radioButton.getBackground()); radioButton.setBackground(null); - assertFalse("getBackground unchanged after setBackground(null) with 0 alpha for SWT.RADIO Button", - radioButton.getBackground().equals(color)); + assertNotEquals("getBackground unchanged after setBackground(null) with 0 alpha for SWT.RADIO Button", + color, radioButton.getBackground()); if ("gtk".equals(SWT.getPlatform ())) { Color fg = new Color(0, 255, 0); radioButton.setBackground(color); @@ -277,7 +280,7 @@ public void test_setForegroundCheckButton() { checkButton.setForeground(color); assertEquals(color, checkButton.getForeground()); checkButton.setForeground(null); - assertFalse(checkButton.getForeground().equals(color)); + assertNotEquals(color, checkButton.getForeground()); if ("gtk".equals(SWT.getPlatform ())) { Color bg = new Color(0, 255, 0); checkButton.setForeground(color); @@ -311,7 +314,7 @@ public void test_setForegroundRadioButton() { radioButton.setForeground(color); assertEquals(color, radioButton.getForeground()); radioButton.setForeground(null); - assertFalse(radioButton.getForeground().equals(color)); + assertNotEquals(color, radioButton.getForeground()); if ("gtk".equals(SWT.getPlatform ())) { Color bg = new Color(0, 255, 0); radioButton.setForeground(color); @@ -409,7 +412,7 @@ public void test_setTextLjava_lang_String() { int goodCases = 4; for (int i=0; i<goodCases; i++){ button.setText(cases[i]); - assertTrue("good case: " + String.valueOf(i), button.getText().equals(cases[i])); + assertEquals("good case: " + String.valueOf(i), cases[i], button.getText()); } try { |