Pattern pattern =
Pattern.compile("(\\d+) Patches and Scenes were deleted");
guiHandler.installDevice("Roland", "Roland D-50");
FrameWrapper library = guiHandler.openLibrary();
JTableFixture table = library.table();
Thread.sleep(100);
guiHandler.newPatch(library, "Roland D-50", D50SingleDriver.class,
listener);
String[][] contents = table.contents();
int rows = contents.length;
assertEquals(1, rows);
JMenuItemFixture menuItem =
testFrame.menuItem(new GenericTypeMatcher<JMenuItem>(
JMenuItem.class) {
@Override
protected boolean isMatching(JMenuItem component) {
return component.getActionCommand().equals(
"Delete Dups...");
}
});
assertFalse(menuItem.target.isEnabled());
guiHandler.newPatch(library, "Roland D-50", D50SingleDriver.class,
listener);
contents = table.contents();
rows = contents.length;
assertEquals(2, rows);
String deleteDups = guiHandler.deleteDups();
Matcher matcher = pattern.matcher(deleteDups);
assertTrue(matcher.find());
int numDeleted = Integer.parseInt(matcher.group(1));
assertEquals(1, numDeleted);
contents = table.contents();
rows = contents.length;
assertEquals(1, rows);
guiHandler.newPatch(library, "Roland D-50", D50SingleDriver.class,
listener);
contents = table.contents();
rows = contents.length;
assertEquals(2, rows);
FrameWrapper patchEditor =
guiHandler.openPatchEditor(table, -1, 0, listener, false);
List<SysexWidget> sysexWidgets =
SysexWidgetFinder.findSysexWidgets(patchEditor);
int numEditedParams = 0;
for (final SysexWidget sysexWidget : sysexWidgets) {
if (sysexWidget instanceof CheckBoxWidget) {
CheckBoxWidget widget = (CheckBoxWidget) sysexWidget;
final JCheckBoxFixture fixture =
new JCheckBoxFixture(testFrame.robot, widget.cb);
if (fixture.target.isEnabled()) {
new SwingCheckBoxValueSetter(fixture, widget.getValueMin())
.setValue(widget.getValueMax());
numEditedParams++;
}
} else if (sysexWidget instanceof ComboBoxWidget) {
ComboBoxWidget widget = (ComboBoxWidget) sysexWidget;
final JComboBoxFixture fixture =
new JComboBoxFixture(testFrame.robot, widget.cb);
if (fixture.target.isEnabled()) {
new SwingComboBoxValueSetter(fixture, widget.getValueMin())
.setValue(widget.getValueMax());
numEditedParams++;
}
} else if (sysexWidget instanceof KnobWidget) {
KnobWidget widget = (KnobWidget) sysexWidget;
if (widget.isEnabled()) {
new SwingKnobValueSetter(widget).setValue(widget.getValueMax());
numEditedParams++;
}
} else if (sysexWidget instanceof ScrollBarWidget) {
ScrollBarWidget widget = (ScrollBarWidget) sysexWidget;
final JSliderFixture fixture =
new JSliderFixture(testFrame.robot, widget.slider);
if (fixture.target.isEnabled()) {
new SwingSliderValueSetter(fixture).setValue(widget
.getValueMax());
numEditedParams++;
}
}
if (numEditedParams == 2) {
break;
}
}
if (patchEditor != null) {
log.info("Close patch editor frame");
guiHandler.closeFrame(patchEditor, true);
}
if (library != null) {
log.info("Selecting library frame");
guiHandler.selectLibraryFrame(library);
}
deleteDups = guiHandler.deleteDups();
matcher = pattern.matcher(deleteDups);
assertTrue(matcher.find());
numDeleted = Integer.parseInt(matcher.group(1));
assertEquals(0, numDeleted);
contents = table.contents();
rows = contents.length;
assertEquals(2, rows);
guiHandler.closeLibrary(library);
guiHandler.uninstallDevice("Roland D-50");