-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from ezweave/master
SquareButtonGrouppo
- Loading branch information
Showing
4 changed files
with
333 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/integTest/java/com/readytalk/swt/widgets/buttons/SquareButtonGroupIntegTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.readytalk.swt.widgets.buttons; | ||
|
||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.events.MouseEvent; | ||
import org.eclipse.swt.layout.FillLayout; | ||
import org.eclipse.swt.widgets.Display; | ||
import org.eclipse.swt.widgets.Event; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class SquareButtonGroupIntegTest { | ||
|
||
private Display display; | ||
private Shell shell; | ||
|
||
private SquareButton toggleOne, toggleTwo, toggleThree, nonToggled; | ||
|
||
private SquareButtonGroup group; | ||
|
||
@Before | ||
public void setUp() { | ||
display = Display.getDefault(); | ||
shell = new Shell(display); | ||
shell.setLayout(new FillLayout()); | ||
|
||
|
||
SquareButton.SquareButtonBuilder builder = new SquareButton.SquareButtonBuilder(); | ||
builder.setParent(shell) | ||
.setText("one") | ||
.setToggleable(true); | ||
toggleOne = builder.build(); | ||
|
||
builder = new SquareButton.SquareButtonBuilder(); | ||
builder.setParent(shell) | ||
.setText("two") | ||
.setToggleable(true); | ||
toggleTwo = builder.build(); | ||
|
||
builder = new SquareButton.SquareButtonBuilder(); | ||
builder.setParent(shell) | ||
.setText("three") | ||
.setToggleable(true); | ||
toggleThree = builder.build(); | ||
|
||
builder = new SquareButton.SquareButtonBuilder(); | ||
builder.setParent(shell) | ||
.setText("non toggle"); | ||
nonToggled = builder.build(); | ||
|
||
group = new SquareButtonGroup(toggleOne, toggleTwo, toggleThree, nonToggled); | ||
|
||
shell.open(); | ||
} | ||
|
||
@Test | ||
public void testDefaultToggle() { | ||
Assert.assertTrue(toggleOne.isToggled()); | ||
Assert.assertFalse(toggleTwo.isToggled()); | ||
Assert.assertFalse(toggleThree.isToggled()); | ||
Assert.assertFalse(nonToggled.isToggled()); | ||
} | ||
|
||
@Test | ||
public void testBasicToggle() { | ||
toggleTwo.notifyListeners(SWT.MouseUp, new Event()); | ||
Assert.assertFalse(toggleOne.isToggled()); | ||
Assert.assertTrue(toggleTwo.isToggled()); | ||
Assert.assertFalse(toggleThree.isToggled()); | ||
Assert.assertFalse(nonToggled.isToggled()); | ||
} | ||
|
||
@Test | ||
public void testDoubleToggle() { | ||
toggleTwo.notifyListeners(SWT.MouseUp, new Event()); | ||
Assert.assertFalse(toggleOne.isToggled()); | ||
Assert.assertTrue(toggleTwo.isToggled()); | ||
Assert.assertFalse(toggleThree.isToggled()); | ||
Assert.assertFalse(nonToggled.isToggled()); | ||
|
||
toggleTwo.notifyListeners(SWT.MouseUp, new Event()); | ||
Assert.assertFalse(toggleOne.isToggled()); | ||
Assert.assertTrue(toggleTwo.isToggled()); | ||
Assert.assertFalse(toggleThree.isToggled()); | ||
Assert.assertFalse(nonToggled.isToggled()); | ||
} | ||
|
||
@Test | ||
public void testForcedSelection() { | ||
group.setCurrentlyToggledButton(toggleThree); | ||
Assert.assertFalse(toggleOne.isToggled()); | ||
Assert.assertFalse(toggleTwo.isToggled()); | ||
Assert.assertTrue(toggleThree.isToggled()); | ||
Assert.assertFalse(nonToggled.isToggled()); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
shell.close(); | ||
display.dispose(); | ||
} | ||
} |
Oops, something went wrong.