added combined bit vectors

This commit is contained in:
eyck committed 2026-11-20 21:08:27 +01:00
1 parent a4215fceb1
commit 42e0d83403
17 files changed
+1066 -14

No files matched your search

@@ -0,0 +1,144 @@
/*******************************************************************************
* Copyright (c) 2026 MINRES Technologies GmbH 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.test;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.atomic.AtomicInteger;
import java.lang.reflect.Proxy;
import org.junit.Test;
import com.minres.scviewer.database.*;
import com.minres.scviewer.database.CombinedBitVectorWaveform.SourceBit;
public class CombinedBitVectorTest {
private static class Signal extends EmptyWaveform {
private final int width;
private final IEventList values = new EventList();
Signal(int id, String name, int width) { super(name); this.width = width; }
void addSignalChange(long time, BitVector value) { values.put(time, value); }
@Override public int getWidth() { return width; }
@Override public WaveformType getType() { return WaveformType.SIGNAL; }
@Override public IEventList getEvents() { return values; }
@Override public IEvent[] getEventsAtTime(long time) { return values.get(time); }
@Override public IEvent[] getEventsBeforeTime(long time) {
var entry = values.floorEntry(time); return entry == null ? new IEvent[0] : entry.events;
}
}
private Signal signal(String name, long[] times, String... values) {
var signal = new Signal(0, name, 1);
for (int i = 0; i < times.length; i++) signal.addSignalChange(times[i], BitVector.fromString(1, values[i]));
return signal;
}
private CombinedBitVectorWaveform combine(IWaveform a, IWaveform b) {
return new CombinedBitVectorWaveform("bus", List.of(new SourceBit(a, 0), new SourceBit(b, 0)));
}
private String value(EventEntry entry) { return entry == null ? null : entry.events[0].toString(); }
@Test public void mergesStaggeredAndSimultaneousChangesAndSuppressesUnchangedValues() {
var a = signal("a", new long[]{5, 20, 20, 25, 30, 40}, "0", "0", "1", "1", "x", "z");
var b = signal("b", new long[]{10, 20, 25}, "1", "0", "0");
var bus = combine(a, b);
var map = bus.getEvents();
assertEquals(List.of(5L, 10L, 20L, 30L, 40L), map.entrySet().stream().map(e -> e.timestamp).toList());
assertEquals(List.of("0x", "01", "10", "x0", "z0"), map.entrySet().stream().map(this::value).toList());
assertEquals(0, bus.getEventsBeforeTime(4).length);
assertEquals("01", bus.getEventsBeforeTime(19)[0].toString());
assertEquals("10", bus.getEventsBeforeTime(25)[0].toString());
assertNull(bus.getEventsAtTime(25));
assertEquals(30, map.higherEntry(20).timestamp);
assertEquals(20, map.lowerEntry(30).timestamp);
assertEquals(20, map.floorEntry(25).timestamp);
assertEquals(30, map.ceilingEntry(25).timestamp);
assertTrue(map.containsKey(20));
assertFalse(map.containsKey(25));
((BitVector) map.get(20)[0]).setValue(0, BitValue.Z);
assertEquals("10", bus.getEventsAtTime(20)[0].toString());
assertEquals("0", b.getEventsAtTime(20)[0].toString());
try { map.put(0, new BitVector(2)); fail(); } catch (UnsupportedOperationException expected) { }
}
@Test public void rangesRemainBoundedAndUseUnsignedTimestamps() {
var a = signal("a", new long[]{0, Long.MAX_VALUE, Long.MIN_VALUE, -1L}, "0", "1", "x", "z");
var b = signal("b", new long[]{0}, "1");
var map = combine(a, b).getEvents();
assertEquals(0, map.firstKey()); assertEquals(-1L, map.lastKey());
assertEquals(Long.MIN_VALUE, map.higherEntry(Long.MAX_VALUE).timestamp);
assertEquals(Long.MAX_VALUE, map.lowerEntry(Long.MIN_VALUE).timestamp);
var range = map.subMap(Long.MAX_VALUE, false, -1L);
assertEquals(2, range.size());
assertNull(range.floorEntry(Long.MAX_VALUE));
assertEquals(Long.MIN_VALUE, range.ceilingEntry(0).timestamp);
assertEquals(-1L, range.floorEntry(-1L).timestamp);
assertNull(range.higherEntry(-1L));
assertEquals(2, range.subMap(0, true, -1L).size());
assertTrue(map.subMap(0, false, 0).isEmpty());
assertTrue(range.subMap(0, true, Long.MAX_VALUE).isEmpty());
try { map.subMap(-1L, true, 0); fail(); } catch (IllegalArgumentException expected) { }
}
@Test public void handlesEmptyInputsAndMissingInitialValues() {
var empty = signal("empty", new long[]{});
var other = signal("other", new long[]{7, 9}, "x", "z");
var bus = combine(empty, other);
assertEquals("xx", value(bus.getEvents().firstEntry()));
assertEquals("xz", value(bus.getEvents().lastEntry()));
assertEquals(2, bus.getEvents().size());
var map = combine(empty, empty).getEvents();
assertTrue(map.isEmpty()); assertEquals(0, map.size());
assertNull(map.firstEntry()); assertNull(map.lastEntry());
assertNull(map.floorEntry(-1L)); assertNull(map.ceilingEntry(0));
try { map.firstKey(); fail(); } catch (NoSuchElementException expected) { }
try { map.lastKey(); fail(); } catch (NoSuchElementException expected) { }
}
@Test public void wideVectorsAndCompositionFlattenToRecordedInputsWithIndependentIdentity() {
var a = signal("a", new long[]{0}, "1");
var b = signal("b", new long[]{0}, "z");
List<SourceBit> bits = new ArrayList<>();
for (int i = 0; i < 80; i++) bits.add(new SourceBit(i % 2 == 0 ? a : b, 0));
var wide = new CombinedBitVectorWaveform("wide", bits);
assertEquals("1z".repeat(40), value(wide.getEvents().firstEntry()));
var combined = new CombinedBitVectorWaveform("bus", List.of(new SourceBit(wide, 1), new SourceBit(wide, 0)));
assertSame(a, combined.getSources().get(0).waveform());
assertSame(b, combined.getSources().get(1).waveform());
assertEquals("1z", value(combined.getEvents().firstEntry()));
assertFalse(combined.isSame(new CombinedBitVectorWaveform("bus", bits)));
var restored = new CombinedBitVectorWaveform(combined.getFullName(), "renamed", combined.getSources());
assertTrue(combined.isSame(restored)); assertEquals("renamed", restored.getDisplayName());
String id = restored.getFullName(); restored.setName("another name"); assertEquals(id, restored.getFullName());
}
@Test public void constructionAndRangeAccessDoNotMaterializeTheRecording() {
AtomicInteger loads = new AtomicInteger();
var delegate = signal("a", new long[]{0, 10, 20}, "0", "1", "0").getEvents();
var source = new Signal(0, "a", 1) {
@Override public IEventList getEvents() {
loads.incrementAndGet();
return (IEventList) Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[]{IEventList.class},
(proxy, method, args) -> {
if (List.of("entrySet", "iterator", "size").contains(method.getName()))
throw new AssertionError("Full source traversal is unnecessary");
return method.invoke(delegate, args);
});
}
};
var bus = combine(source, source);
var range = bus.getEvents().subMap(5, true, 15);
assertEquals(0, loads.get());
assertEquals("11", value(range.firstEntry()));
assertEquals(2, loads.get());
assertEquals("11", value(range.lastEntry()));
assertEquals(2, loads.get());
}
}
@@ -72,6 +72,39 @@ public class CommandHandlersTest {
(proxy, method, args) -> method.getName().equals("getActivePart") ? active.get() : null);
}
@Test
public void combineHandlerRoutesToActiveViewerAndHonorsDialogCancellation() {
var first = new TrackEntry(waveform(WaveformType.SIGNAL), null);
var second = new TrackEntry(waveform(WaveformType.SIGNAL), null);
class CombineViewer extends Viewer {
boolean enabled = true;
CombineBitsHandler.Request request;
@Override public List<TrackEntry> selectedBits() { return enabled ? List.of(first, second) : List.of(); }
@Override public void combineBits(String name, List<TrackEntry> bits) {
request = new CombineBitsHandler.Request(name, bits);
}
}
CombineViewer viewer = new CombineViewer();
AtomicReference<MPart> active = new AtomicReference<>();
var service = parts(active);
AtomicReference<CombineBitsHandler.Request> answer = new AtomicReference<>();
CombineBitsHandler handler = new CombineBitsHandler() {
@Override protected Request requestVector(org.eclipse.swt.widgets.Shell shell, List<TrackEntry> bits) {
assertEquals(List.of(first, second), bits); return answer.get();
}
};
try {
assertFalse(handler.canExecute(service)); handler.execute(service, null);
active.set(part(viewer)); assertTrue(handler.canExecute(service));
handler.execute(service, null); assertNull(viewer.request);
answer.set(new CombineBitsHandler.Request("bus", List.of(second, first)));
handler.execute(service, null); assertEquals(answer.get(), viewer.request);
viewer.enabled = false; viewer.request = null;
assertFalse(handler.canExecute(service)); handler.execute(service, null); assertNull(viewer.request);
active.set(part(new Object())); assertFalse(handler.canExecute(service));
} finally { viewer.closeDatabase(); }
}
@Test
public void groupingHandlersFollowActivePartAndGuardMissingSelection() {
class GroupViewer extends Viewer {
@@ -172,7 +172,7 @@ public class BitVectorExpansionTest {
assertEquals(5, TrackEntry.visibleTracks(List.of(restored)).size());
}
private List<TrackEntry> restore(ViewerSettings settings, IWaveformDb database) throws Exception {
List<TrackEntry> restore(ViewerSettings settings, IWaveformDb database) throws Exception {
var roots = new ArrayList<TrackEntry>();
var paneType = com.minres.scviewer.database.ui.IWaveformView.class;
var zoomType = com.minres.scviewer.database.ui.IWaveformZoom.class;
@@ -0,0 +1,136 @@
/*******************************************************************************
* Copyright (c) 2026 MINRES Technologies GmbH 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.e4.application.parts;
import static org.junit.Assert.*;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import com.minres.scviewer.database.*;
import com.minres.scviewer.database.CombinedBitVectorWaveform.SourceBit;
import com.minres.scviewer.database.ui.*;
import com.minres.scviewer.e4.application.internal.util.ViewerSettings;
public class CombinedVectorSettingsTest {
private final BitVectorExpansionTest.Signal input = new BitVectorExpansionTest.Signal("top.input", 4);
private IWaveformDb database() {
return (IWaveformDb) Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[]{IWaveformDb.class},
(proxy, method, args) -> method.getName().equals("getStreamByName")
&& input.getFullName().equals(args[0]) ? input : null);
}
private CombinedBitVectorWaveform vector() {
input.events.put(0, BitVector.fromString(4, "10xz"));
return new CombinedBitVectorWaveform("same label", List.of(new SourceBit(input, 0), new SourceBit(input, 3)));
}
private ViewerSettings capture(List<TrackEntry> roots) throws Exception {
var tracks = new ArrayList<ViewerSettings.Track>();
Map<String, ViewerSettings.CombinedVector> definitions = new LinkedHashMap<>();
var capture = WaveformViewer.class.getDeclaredMethod("captureTracks", List.class, Integer.class, List.class);
capture.setAccessible(true); capture.invoke(null, roots, null, tracks);
var combined = WaveformViewer.class.getDeclaredMethod("captureCombined", List.class, Map.class);
combined.setAccessible(true); combined.invoke(null, roots, definitions);
return new ViewerSettings(tracks, List.of(), null, null, null, null, null, List.of(), List.copyOf(definitions.values()));
}
@Test public void eligibilityAcceptsExpandedBitsAndRejectsMixedOrUnrelatedSelections() {
var bus = new TrackEntry(vector(), null); bus.setExpanded(true);
var roots = List.of(TrackEntry.group("group", List.of(bus), null));
var first = bus.waveforms.get(0); var second = bus.waveforms.get(1);
assertEquals(List.of(first, second), BitVectorComposition.selectedBits(roots, List.of(second, first)));
assertTrue(BitVectorComposition.selectedBits(roots, List.of(bus, first)).isEmpty());
assertTrue(BitVectorComposition.selectedBits(roots, List.of(first)).isEmpty());
assertTrue(BitVectorComposition.selectedBits(roots, List.of(first, new TrackEntry(input, null))).isEmpty());
var real = new BitVectorExpansionTest.Signal("real", 1);
real.events.put(0, new DoubleVal(1.0));
assertFalse(BitVectorComposition.isSingleBit(new TrackEntry(real, null)));
var sources = BitVectorComposition.sources(List.of(second, first));
var combined = new CombinedBitVectorWaveform("reversed", sources);
assertEquals("1z", combined.getEventsBeforeTime(0)[0].toString());
assertSame(input, combined.getSources().get(0).waveform());
}
@Test public void expandedVectorsRoundTripWithIdentitySeparateFromLabelsAndBitOrdering() throws Exception {
var vector = vector();
var bus = new TrackEntry(vector, null); bus.setExpanded(true);
var other = new TrackEntry(new CombinedBitVectorWaveform(vector.getName(), vector.getSources()), null);
var settings = capture(List.of(TrackEntry.group("group", List.of(bus, other), null)));
var parsed = ViewerSettings.parse(settings.toMap());
assertEquals(settings, parsed);
assertEquals(2, parsed.combinedVectors().size());
assertEquals("same label", parsed.combinedVectors().get(0).name());
assertNotEquals(parsed.combinedVectors().get(0).id(), parsed.combinedVectors().get(1).id());
var roots = new BitVectorExpansionTest().restore(parsed, database());
var restored = roots.get(0).waveforms.get(0);
assertEquals(TrackEntry.HierState.OPENED, restored.hierState);
assertEquals(2, restored.waveforms.size());
assertEquals("same label", restored.waveform.getDisplayName());
assertEquals("z1", restored.waveform.getEventsBeforeTime(0)[0].toString());
assertEquals("same label[1]", restored.waveforms.get(0).waveform.getDisplayName());
assertEquals("z", restored.waveforms.get(0).waveform.getEventsBeforeTime(0)[0].toString());
assertEquals(2, roots.get(0).waveforms.size());
}
@Test public void survivingBitRetainsDefinitionWhenOriginalBusWasDeleted() throws Exception {
var bit = new TrackEntry(new BitWaveform(vector(), 1), null);
var settings = capture(List.of(bit));
assertEquals(1, settings.combinedVectors().size());
var restored = new BitVectorExpansionTest().restore(settings, database());
assertEquals(1, restored.size());
assertEquals("z", restored.get(0).waveform.getEventsBeforeTime(0)[0].toString());
}
@Test public void missingInputsSkipWholeBusAndLeaveOtherTracksIntact() throws Exception {
var bus = new TrackEntry(vector(), null); bus.setExpanded(true);
var settings = capture(List.of(bus, new TrackEntry(input, null)));
var map = new HashMap<>(settings.toMap());
map.put("COMBINED_VECTOR0.BIT0.SOURCE", "missing.source");
settings = ViewerSettings.parse(map);
List<String> missing = new ArrayList<>();
assertTrue(settings.resolveCombinedVectors(database(), missing).isEmpty());
assertTrue(missing.get(0).contains("missing.source"));
var roots = new BitVectorExpansionTest().restore(settings, database());
assertEquals(1, roots.size()); assertSame(input, roots.get(0).waveform);
map.put("COMBINED_VECTOR0.BIT0.SOURCE", input.getFullName());
map.put("COMBINED_VECTOR0.BIT0.INDEX", "99");
assertTrue(ViewerSettings.parse(map).resolveCombinedVectors(database(), new ArrayList<>()).isEmpty());
}
@Test public void validatesDefinitionsAndRemovesObsoleteDefinitionsWhenReplacingState() throws Exception {
var settings = capture(List.of(new TrackEntry(vector(), null)));
for (Map.Entry<String, String> invalid : Map.of(
"COMBINED_VECTOR0.BIT0.INDEX", "-1",
"COMBINED_VECTOR0.BIT1.INDEX", "99999999999",
"COMBINED_VECTOR0.BIT0.SOURCE", settings.combinedVectors().get(0).id(),
"COMBINED_VECTOR0.BITS", "1",
"COMBINED_VECTOR0.NAME", " ").entrySet()) {
var map = new HashMap<>(settings.toMap()); map.put(invalid.getKey(), invalid.getValue());
try { ViewerSettings.parse(map); fail("Accepted " + invalid); } catch (IllegalArgumentException expected) { }
}
var map = new HashMap<>(settings.toMap());
ViewerSettings legacy = ViewerSettings.parse(Map.of());
legacy.replaceState(map);
assertEquals(legacy, ViewerSettings.parse(map));
assertFalse(map.containsKey("COMBINED_VECTOR0.ID"));
assertTrue(ViewerSettings.parse(Map.of()).combinedVectors().isEmpty());
var duplicate = new HashMap<>(settings.toMap());
duplicate.put("COMBINED_VECTORS", "2");
settings.toMap().forEach((key, value) -> {
if (key.startsWith("COMBINED_VECTOR0."))
duplicate.put(key.replace("COMBINED_VECTOR0.", "COMBINED_VECTOR1."), value);
});
try { ViewerSettings.parse(duplicate); fail("Accepted duplicate identities"); }
catch (IllegalArgumentException expected) { }
}
}
@@ -123,6 +123,153 @@ public class WaveformScrollTest {
} finally { gc.dispose(); image.dispose(); }
}
private WaveformViewer compositionViewer(java.util.function.Consumer<Runnable> dispatch) throws Exception {
WaveformViewer viewer = new WaveformViewer();
var pane = WaveformViewer.class.getDeclaredField("waveformPane");
pane.setAccessible(true); pane.set(viewer, view);
var synchronizer = WaveformViewer.class.getDeclaredField("sync");
synchronizer.setAccessible(true);
synchronizer.set(viewer, new org.eclipse.e4.ui.di.UISynchronize() {
@Override public void asyncExec(Runnable runnable) { dispatch.accept(runnable); }
@Override public void syncExec(Runnable runnable) { display.syncExec(runnable); }
@Override protected boolean isUIThread(Thread thread) { return thread == display.getThread(); }
@Override protected void showBusyWhile(Runnable runnable) { runnable.run(); }
@Override protected boolean dispatchEvents() { return display.readAndDispatch(); }
});
return viewer;
}
private List<TrackEntry> scalarInputs() {
var a = new BitVectorExpansionTest.Signal("a", 1);
var b = new BitVectorExpansionTest.Signal("b", 1);
a.events.put(0, com.minres.scviewer.database.BitVector.fromString(1, "0"));
b.events.put(0, com.minres.scviewer.database.BitVector.fromString(1, "1"));
TrackEntry first = view.addWaveform(a, -1), second = view.addWaveform(b, -1);
view.update();
return List.of(first, second);
}
private void waitUntil(java.util.function.BooleanSupplier condition) throws Exception {
long deadline = System.nanoTime() + java.util.concurrent.TimeUnit.SECONDS.toNanos(10);
while (!condition.getAsBoolean()) {
drainEvents();
if (System.nanoTime() > deadline) fail("Timed out waiting for the combine job");
Thread.sleep(5);
}
}
@Test
public void combinesInRequestedOrderWithoutRemovingSourcesAndSupportsExpansion() throws Exception {
var inputs = scalarInputs();
TrackEntry tail = view.addWaveform(new EmptyWaveform("tail"), -1);
view.setSelection(new StructuredSelection(List.of(inputs.get(1), inputs.get(0))));
WaveformViewer viewer = compositionViewer(display::asyncExec);
try {
assertEquals(inputs, viewer.selectedBits());
assertTrue(viewer.canCombineSelectedBits());
viewer.combineBits("bus", List.of(inputs.get(1), inputs.get(0)));
waitUntil(() -> view.getStreamList().size() == 4);
TrackEntry bus = view.getStreamList().get(2);
assertEquals("bus", bus.waveform.getDisplayName());
assertEquals("10", bus.waveform.getEventsBeforeTime(0)[0].toString());
assertEquals(List.of(inputs.get(0), inputs.get(1), bus, tail), view.getStreamList());
assertSame(bus, ((StructuredSelection) view.getSelection()).getFirstElement());
view.setGroupExpanded(bus, true);
assertEquals(6, TrackEntry.visibleTracks(view.getStreamList()).size());
assertEquals("b'1", bus.waveforms.get(0).currentValue);
assertEquals("b'0", bus.waveforms.get(1).currentValue);
view.setGroupExpanded(bus, false);
assertEquals(4, TrackEntry.visibleTracks(view.getStreamList()).size());
view.deleteSelectedTracks(); drainEvents();
assertEquals(List.of(inputs.get(0), inputs.get(1), tail), view.getStreamList());
} finally { viewer.closeDatabase(); }
}
@Test
public void combinedVectorsAreTopLevelAfterLastSelectedBitsContainingRoot() throws Exception {
var inputs = scalarInputs();
var source = new BitVectorExpansionTest.Signal("original bus", 2);
source.events.put(0, com.minres.scviewer.database.BitVector.fromString(2, "10"));
TrackEntry bus = new TrackEntry(source, null);
bus.setExpanded(true);
var originalBits = List.copyOf(bus.waveforms);
TrackEntry inner = TrackEntry.group("inner", List.of(bus, inputs.get(1)), null);
TrackEntry outer = TrackEntry.group("outer", List.of(inner), null);
TrackEntry tail = new TrackEntry(new EmptyWaveform("tail"), null);
view.getStreamList().clear();
view.getStreamList().addAll(List.of(inputs.get(0), outer, tail));
view.update();
WaveformViewer viewer = compositionViewer(display::asyncExec);
try {
viewer.combineBits("from bus", List.of(originalBits.get(1), originalBits.get(0)));
waitUntil(() -> view.getStreamList().size() == 4);
TrackEntry combined = view.getStreamList().get(2);
assertEquals("from bus", combined.waveform.getDisplayName());
assertEquals(List.of(inputs.get(0), outer, combined, tail), view.getStreamList());
assertEquals(List.of(bus, inputs.get(1)), inner.waveforms);
assertEquals(originalBits, bus.waveforms);
viewer.combineBits("mixed", List.of(originalBits.get(0), inputs.get(0)));
waitUntil(() -> view.getStreamList().size() == 5);
TrackEntry mixed = view.getStreamList().get(2);
assertEquals("mixed", mixed.waveform.getDisplayName());
assertEquals("10", mixed.waveform.getEventsBeforeTime(0)[0].toString());
assertEquals(List.of(inputs.get(0), outer, mixed, combined, tail), view.getStreamList());
assertEquals(originalBits, bus.waveforms);
} finally { viewer.closeDatabase(); }
}
@Test
public void closingViewerRejectsACombineResultAlreadyQueuedForPublication() throws Exception {
var inputs = scalarInputs();
var pending = new java.util.concurrent.CopyOnWriteArrayList<Runnable>();
WaveformViewer viewer = compositionViewer(pending::add);
viewer.combineBits("bus", inputs);
waitUntil(() -> !pending.isEmpty());
viewer.closeDatabase();
pending.forEach(Runnable::run);
assertEquals(inputs, view.getStreamList());
assertFalse(viewer.canCombineSelectedBits());
}
private List<org.eclipse.swt.widgets.Control> descendants(org.eclipse.swt.widgets.Composite parent) {
var controls = new ArrayList<org.eclipse.swt.widgets.Control>();
for (var child : parent.getChildren()) {
controls.add(child);
if (child instanceof org.eclipse.swt.widgets.Composite composite) controls.addAll(descendants(composite));
}
return controls;
}
@Test
public void combineDialogLabelsDestinationBitsAndAllowsReorderingAndNameValidation() {
var inputs = scalarInputs();
class Dialog extends com.minres.scviewer.e4.application.handlers.CombineBitsHandler.CombineDialog {
Dialog() { super(shell, inputs); }
void accept() { okPressed(); }
}
Dialog dialog = new Dialog();
dialog.create();
try {
var controls = descendants(dialog.getShell());
var table = (org.eclipse.swt.widgets.Table) controls.stream()
.filter(org.eclipse.swt.widgets.Table.class::isInstance).findFirst().orElseThrow();
assertEquals("1", table.getItem(0).getText(0));
assertEquals("a", table.getItem(0).getText(1));
var down = (org.eclipse.swt.widgets.Button) controls.stream()
.filter(control -> control instanceof org.eclipse.swt.widgets.Button button
&& button.getText().equals("Move down")).findFirst().orElseThrow();
down.notifyListeners(SWT.Selection, new Event());
assertEquals("b", table.getItem(0).getText(1));
var name = (org.eclipse.swt.widgets.Text) controls.stream()
.filter(org.eclipse.swt.widgets.Text.class::isInstance).findFirst().orElseThrow();
name.setText(" "); dialog.accept();
assertNull(dialog.getRequest()); assertFalse(dialog.getShell().isDisposed());
name.setText("ordered"); dialog.accept();
assertEquals("ordered", dialog.getRequest().name());
assertEquals(List.of(inputs.get(1), inputs.get(0)), dialog.getRequest().bits());
} finally { if (dialog.getShell() != null && !dialog.getShell().isDisposed()) dialog.close(); }
}
@Test
public void bitvectorDisclosureUpdatesAllPanesAndCursorValues() {
var source = new BitVectorExpansionTest.Signal("bus", 4);